@rjsf/core 5.0.0-beta.16 → 5.0.0-beta.18

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.
@@ -5,26 +5,26 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
  var utils = require('@rjsf/utils');
7
7
  var get = require('lodash/get');
8
- var _isEmpty = require('lodash/isEmpty');
8
+ var isEmpty = require('lodash/isEmpty');
9
9
  var _pick = require('lodash/pick');
10
10
  var isObject = require('lodash/isObject');
11
11
  var set = require('lodash/set');
12
12
  var nanoid = require('nanoid');
13
- var unset = require('lodash/unset');
14
- var has = require('lodash/has');
15
13
  var omit = require('lodash/omit');
14
+ var has = require('lodash/has');
15
+ var unset = require('lodash/unset');
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
18
 
19
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
20
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
21
- var _isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(_isEmpty);
21
+ var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
22
22
  var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
23
23
  var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
24
24
  var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
25
- var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
26
- var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
27
25
  var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
26
+ var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
27
+ var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
28
28
 
29
29
  function _defineProperties(target, props) {
30
30
  for (var i = 0; i < props.length; i++) {
@@ -32,7 +32,7 @@ function _defineProperties(target, props) {
32
32
  descriptor.enumerable = descriptor.enumerable || false;
33
33
  descriptor.configurable = true;
34
34
  if ("value" in descriptor) descriptor.writable = true;
35
- Object.defineProperty(target, descriptor.key, descriptor);
35
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
36
36
  }
37
37
  }
38
38
  function _createClass(Constructor, protoProps, staticProps) {
@@ -81,36 +81,19 @@ function _objectWithoutPropertiesLoose(source, excluded) {
81
81
  }
82
82
  return target;
83
83
  }
84
- function _unsupportedIterableToArray(o, minLen) {
85
- if (!o) return;
86
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
87
- var n = Object.prototype.toString.call(o).slice(8, -1);
88
- if (n === "Object" && o.constructor) n = o.constructor.name;
89
- if (n === "Map" || n === "Set") return Array.from(o);
90
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
91
- }
92
- function _arrayLikeToArray(arr, len) {
93
- if (len == null || len > arr.length) len = arr.length;
94
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
95
- return arr2;
96
- }
97
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
98
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
99
- if (it) return (it = it.call(o)).next.bind(it);
100
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
101
- if (it) o = it;
102
- var i = 0;
103
- return function () {
104
- if (i >= o.length) return {
105
- done: true
106
- };
107
- return {
108
- done: false,
109
- value: o[i++]
110
- };
111
- };
84
+ function _toPrimitive(input, hint) {
85
+ if (typeof input !== "object" || input === null) return input;
86
+ var prim = input[Symbol.toPrimitive];
87
+ if (prim !== undefined) {
88
+ var res = prim.call(input, hint || "default");
89
+ if (typeof res !== "object") return res;
90
+ throw new TypeError("@@toPrimitive must return a primitive value.");
112
91
  }
113
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
92
+ return (hint === "string" ? String : Number)(input);
93
+ }
94
+ function _toPropertyKey(arg) {
95
+ var key = _toPrimitive(arg, "string");
96
+ return typeof key === "symbol" ? key : String(key);
114
97
  }
115
98
 
116
99
  var _excluded$9 = ["widget"],
@@ -538,7 +521,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
538
521
  options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
539
522
  var Widget = utils.getWidget(schema, widget, widgets);
540
523
  return /*#__PURE__*/React__default["default"].createElement(Widget, {
541
- id: idSchema && idSchema.$id,
524
+ id: idSchema.$id,
542
525
  multiple: true,
543
526
  onChange: this.onSelectChange,
544
527
  onBlur: onBlur,
@@ -594,7 +577,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
594
577
  options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
595
578
  var Widget = utils.getWidget(schema, widget, widgets);
596
579
  return /*#__PURE__*/React__default["default"].createElement(Widget, {
597
- id: idSchema && idSchema.$id,
580
+ id: idSchema.$id,
598
581
  multiple: true,
599
582
  onChange: this.onSelectChange,
600
583
  onBlur: onBlur,
@@ -648,7 +631,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
648
631
  var Widget = utils.getWidget(schema, widget, widgets);
649
632
  return /*#__PURE__*/React__default["default"].createElement(Widget, {
650
633
  options: options,
651
- id: idSchema && idSchema.$id,
634
+ id: idSchema.$id,
652
635
  multiple: true,
653
636
  onChange: this.onSelectChange,
654
637
  onBlur: onBlur,
@@ -941,7 +924,7 @@ function BooleanField(props) {
941
924
  }),
942
925
  schema: schema,
943
926
  uiSchema: uiSchema,
944
- id: idSchema && idSchema.$id,
927
+ id: idSchema.$id,
945
928
  onChange: onChange,
946
929
  onFocus: onFocus,
947
930
  onBlur: onBlur,
@@ -957,7 +940,7 @@ function BooleanField(props) {
957
940
  });
958
941
  }
959
942
 
960
- var _excluded$7 = ["widget"];
943
+ var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete"];
961
944
  /** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
962
945
  * the currently selected option and cleans up any irrelevant data in `formData`.
963
946
  *
@@ -973,38 +956,28 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
973
956
  var _this;
974
957
  _this = _Component.call(this, props) || this;
975
958
  _this.onOptionChange = function (option) {
976
- var selectedOption = parseInt(option, 10);
959
+ var selectedOption = _this.state.selectedOption;
977
960
  var _this$props = _this.props,
978
961
  formData = _this$props.formData,
979
962
  onChange = _this$props.onChange,
980
963
  options = _this$props.options,
981
964
  registry = _this$props.registry;
982
965
  var schemaUtils = registry.schemaUtils;
983
- var newOption = schemaUtils.retrieveSchema(options[selectedOption], formData);
984
- // If the new option is of type object and the current data is an object,
985
- // discard properties added using the old option.
986
- var newFormData = undefined;
987
- if (utils.guessType(formData) === "object" && (newOption.type === "object" || newOption.properties)) {
988
- newFormData = Object.assign({}, formData);
989
- var optionsToDiscard = options.slice();
990
- optionsToDiscard.splice(selectedOption, 1);
991
- // Discard any data added using other options
992
- for (var _iterator = _createForOfIteratorHelperLoose(optionsToDiscard), _step; !(_step = _iterator()).done;) {
993
- var _option = _step.value;
994
- if (_option.properties) {
995
- for (var key in _option.properties) {
996
- if (key in newFormData) {
997
- unset__default["default"](newFormData, key);
998
- }
999
- }
1000
- }
1001
- }
966
+ var intOption = option !== undefined ? parseInt(option, 10) : -1;
967
+ if (intOption === selectedOption) {
968
+ return;
969
+ }
970
+ var newOption = intOption >= 0 ? schemaUtils.retrieveSchema(options[intOption], formData) : undefined;
971
+ var oldOption = selectedOption >= 0 ? schemaUtils.retrieveSchema(options[selectedOption], formData) : undefined;
972
+ var newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
973
+ if (newFormData && newOption) {
974
+ // Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
975
+ // so that only the root objects themselves are created without adding undefined children properties
976
+ newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
1002
977
  }
1003
- // Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
1004
- // so that only the root objects themselves are created without adding undefined children properties
1005
- onChange(schemaUtils.getDefaultFormState(options[selectedOption], newFormData, "excludeObjectChildren"), undefined, _this.getFieldId());
978
+ onChange(newFormData, undefined, _this.getFieldId());
1006
979
  _this.setState({
1007
- selectedOption: parseInt(option, 10)
980
+ selectedOption: intOption
1008
981
  });
1009
982
  };
1010
983
  var _this$props2 = _this.props,
@@ -1046,8 +1019,8 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1046
1019
  */;
1047
1020
  _proto.getMatchingOption = function getMatchingOption(selectedOption, formData, options) {
1048
1021
  var schemaUtils = this.props.registry.schemaUtils;
1049
- var option = schemaUtils.getMatchingOption(formData, options);
1050
- if (option !== 0) {
1022
+ var option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption);
1023
+ if (option > 0) {
1051
1024
  return option;
1052
1025
  }
1053
1026
  // If the form data matches none of the options, use the currently selected
@@ -1070,23 +1043,13 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1070
1043
  */;
1071
1044
  _proto.render = function render() {
1072
1045
  var _this$props5 = this.props,
1073
- name = _this$props5.name,
1074
1046
  baseType = _this$props5.baseType,
1075
1047
  _this$props5$disabled = _this$props5.disabled,
1076
1048
  disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
1077
- _this$props5$readonly = _this$props5.readonly,
1078
- readonly = _this$props5$readonly === void 0 ? false : _this$props5$readonly,
1079
- _this$props5$hideErro = _this$props5.hideError,
1080
- hideError = _this$props5$hideErro === void 0 ? false : _this$props5$hideErro,
1081
1049
  _this$props5$errorSch = _this$props5.errorSchema,
1082
1050
  errorSchema = _this$props5$errorSch === void 0 ? {} : _this$props5$errorSch,
1083
- formData = _this$props5.formData,
1084
1051
  formContext = _this$props5.formContext,
1085
- idPrefix = _this$props5.idPrefix,
1086
- idSeparator = _this$props5.idSeparator,
1087
- idSchema = _this$props5.idSchema,
1088
1052
  onBlur = _this$props5.onBlur,
1089
- onChange = _this$props5.onChange,
1090
1053
  onFocus = _this$props5.onFocus,
1091
1054
  options = _this$props5.options,
1092
1055
  registry = _this$props5.registry,
@@ -1098,10 +1061,15 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1098
1061
  var _getUiOptions = utils.getUiOptions(uiSchema),
1099
1062
  _getUiOptions$widget = _getUiOptions.widget,
1100
1063
  widget = _getUiOptions$widget === void 0 ? "select" : _getUiOptions$widget,
1064
+ placeholder = _getUiOptions.placeholder,
1065
+ autofocus = _getUiOptions.autofocus,
1066
+ autocomplete = _getUiOptions.autocomplete,
1101
1067
  uiOptions = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$7);
1102
1068
  var Widget = utils.getWidget({
1103
1069
  type: "number"
1104
1070
  }, widget, widgets);
1071
+ var rawErrors = get__default["default"](errorSchema, utils.ERRORS_KEY, []);
1072
+ var fieldErrorSchema = omit__default["default"](errorSchema, [utils.ERRORS_KEY]);
1105
1073
  var option = options[selectedOption] || null;
1106
1074
  var optionSchema;
1107
1075
  if (option) {
@@ -1121,7 +1089,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1121
1089
  className: "panel panel-default panel-body"
1122
1090
  }, /*#__PURE__*/React__default["default"].createElement("div", {
1123
1091
  className: "form-group"
1124
- }, /*#__PURE__*/React__default["default"].createElement(Widget, _extends({
1092
+ }, /*#__PURE__*/React__default["default"].createElement(Widget, {
1125
1093
  id: this.getFieldId(),
1126
1094
  schema: {
1127
1095
  type: "number",
@@ -1130,32 +1098,23 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1130
1098
  onChange: this.onOptionChange,
1131
1099
  onBlur: onBlur,
1132
1100
  onFocus: onFocus,
1101
+ disabled: disabled || isEmpty__default["default"](enumOptions),
1102
+ multiple: false,
1103
+ rawErrors: rawErrors,
1104
+ errorSchema: fieldErrorSchema,
1133
1105
  value: selectedOption,
1134
- options: {
1106
+ options: _extends({
1135
1107
  enumOptions: enumOptions
1136
- },
1108
+ }, uiOptions),
1137
1109
  registry: registry,
1138
- formContext: formContext
1139
- }, uiOptions, {
1140
- label: ""
1141
- }))), option !== null && /*#__PURE__*/React__default["default"].createElement(_SchemaField, {
1142
- name: name,
1143
- schema: optionSchema,
1144
- uiSchema: uiSchema,
1145
- errorSchema: errorSchema,
1146
- idSchema: idSchema,
1147
- idPrefix: idPrefix,
1148
- idSeparator: idSeparator,
1149
- formData: formData,
1150
1110
  formContext: formContext,
1151
- onChange: onChange,
1152
- onBlur: onBlur,
1153
- onFocus: onFocus,
1154
- registry: registry,
1155
- disabled: disabled,
1156
- readonly: readonly,
1157
- hideError: hideError
1158
- }));
1111
+ placeholder: placeholder,
1112
+ autocomplete: autocomplete,
1113
+ autofocus: autofocus,
1114
+ label: ""
1115
+ })), option !== null && /*#__PURE__*/React__default["default"].createElement(_SchemaField, _extends({}, this.props, {
1116
+ schema: optionSchema
1117
+ })));
1159
1118
  };
1160
1119
  return AnyOfField;
1161
1120
  }(React.Component);
@@ -1291,7 +1250,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
1291
1250
  duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? "-" : _getUiOptions$duplica;
1292
1251
  var index = 0;
1293
1252
  var newKey = preferredKey;
1294
- while (newKey in formData) {
1253
+ while (has__default["default"](formData, newKey)) {
1295
1254
  newKey = "" + preferredKey + duplicateKeySuffixSeparator + ++index;
1296
1255
  }
1297
1256
  return newKey;
@@ -1334,12 +1293,16 @@ var ObjectField = /*#__PURE__*/function (_Component) {
1334
1293
  var type = undefined;
1335
1294
  if (isObject__default["default"](schema.additionalProperties)) {
1336
1295
  type = schema.additionalProperties.type;
1337
- if (utils.REF_KEY in schema.additionalProperties) {
1296
+ var apSchema = schema.additionalProperties;
1297
+ if (utils.REF_KEY in apSchema) {
1338
1298
  var schemaUtils = registry.schemaUtils;
1339
- var refSchema = schemaUtils.retrieveSchema({
1340
- $ref: schema.additionalProperties[utils.REF_KEY]
1299
+ apSchema = schemaUtils.retrieveSchema({
1300
+ $ref: apSchema[utils.REF_KEY]
1341
1301
  }, formData);
1342
- type = refSchema.type;
1302
+ type = apSchema.type;
1303
+ }
1304
+ if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
1305
+ type = "object";
1343
1306
  }
1344
1307
  }
1345
1308
  var newKey = _this.getAvailableKey("newKey", newFormData);
@@ -1602,10 +1565,10 @@ function SchemaFieldRender(props) {
1602
1565
  var _ref = errorSchema || {},
1603
1566
  __errors = _ref.__errors,
1604
1567
  fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1605
- // See #439: uiSchema: Don't pass consumed class names to child components
1606
- var fieldUiSchema = omit__default["default"](uiSchema, ["ui:classNames", "classNames"]);
1607
- if ("ui:options" in fieldUiSchema) {
1608
- fieldUiSchema["ui:options"] = omit__default["default"](fieldUiSchema["ui:options"], ["classNames"]);
1568
+ // See #439: uiSchema: Don't pass consumed class names or style to child components
1569
+ var fieldUiSchema = omit__default["default"](uiSchema, ["ui:classNames", "classNames", "ui:style"]);
1570
+ if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
1571
+ fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], ["classNames", "style"]);
1609
1572
  }
1610
1573
  var field = /*#__PURE__*/React__default["default"].createElement(FieldComponent, _extends({}, props, {
1611
1574
  onChange: handleFieldComponentChange,
@@ -1662,7 +1625,7 @@ function SchemaFieldRender(props) {
1662
1625
  });
1663
1626
  var fieldProps = {
1664
1627
  description: /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
1665
- id: id + "__description",
1628
+ id: utils.descriptionId(id),
1666
1629
  description: description,
1667
1630
  schema: schema,
1668
1631
  uiSchema: uiSchema,
@@ -1685,6 +1648,7 @@ function SchemaFieldRender(props) {
1685
1648
  hideError: hideError,
1686
1649
  displayLabel: displayLabel,
1687
1650
  classNames: classNames.join(" ").trim(),
1651
+ style: uiOptions.style,
1688
1652
  formContext: formContext,
1689
1653
  formData: formData,
1690
1654
  schema: schema,
@@ -1801,7 +1765,7 @@ function StringField(props) {
1801
1765
  }),
1802
1766
  schema: schema,
1803
1767
  uiSchema: uiSchema,
1804
- id: idSchema && idSchema.$id,
1768
+ id: idSchema.$id,
1805
1769
  label: title === undefined ? name : title,
1806
1770
  value: formData,
1807
1771
  onChange: onChange,
@@ -1867,9 +1831,8 @@ function ArrayFieldDescriptionTemplate(props) {
1867
1831
  return null;
1868
1832
  }
1869
1833
  var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, options);
1870
- var id = idSchema.$id + "__description";
1871
1834
  return /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
1872
- id: id,
1835
+ id: utils.descriptionId(idSchema),
1873
1836
  description: description,
1874
1837
  schema: schema,
1875
1838
  uiSchema: uiSchema,
@@ -2014,9 +1977,8 @@ function ArrayFieldTitleTemplate(props) {
2014
1977
  return null;
2015
1978
  }
2016
1979
  var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, options);
2017
- var id = idSchema.$id + "__title";
2018
1980
  return /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
2019
- id: id,
1981
+ id: utils.titleId(idSchema),
2020
1982
  title: title,
2021
1983
  required: required,
2022
1984
  schema: schema,
@@ -2079,13 +2041,14 @@ function BaseInputTemplate(props) {
2079
2041
  autoFocus: autofocus,
2080
2042
  value: inputValue
2081
2043
  }, inputProps, {
2082
- list: schema.examples ? "examples_" + id : undefined,
2044
+ list: schema.examples ? utils.examplesId(id) : undefined,
2083
2045
  onChange: _onChange,
2084
2046
  onBlur: _onBlur,
2085
- onFocus: _onFocus
2047
+ onFocus: _onFocus,
2048
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
2086
2049
  })), Array.isArray(schema.examples) && /*#__PURE__*/React__default["default"].createElement("datalist", {
2087
2050
  key: "datalist_" + id,
2088
- id: "examples_" + id
2051
+ id: utils.examplesId(id)
2089
2052
  }, [].concat(new Set(schema.examples.concat(schema["default"] ? [schema["default"]] : []))).map(function (example) {
2090
2053
  return /*#__PURE__*/React__default["default"].createElement("option", {
2091
2054
  key: example,
@@ -2292,7 +2255,7 @@ function FieldErrorTemplate(props) {
2292
2255
  if (errors.length === 0) {
2293
2256
  return null;
2294
2257
  }
2295
- var id = idSchema.$id + "__error";
2258
+ var id = utils.errorId(idSchema);
2296
2259
  return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
2297
2260
  id: id,
2298
2261
  className: "error-detail bs-callout bs-callout-info"
@@ -2316,7 +2279,7 @@ function FieldHelpTemplate(props) {
2316
2279
  if (!help) {
2317
2280
  return null;
2318
2281
  }
2319
- var id = idSchema.$id + "__help";
2282
+ var id = utils.helpId(idSchema);
2320
2283
  if (typeof help === "string") {
2321
2284
  return /*#__PURE__*/React__default["default"].createElement("p", {
2322
2285
  id: id,
@@ -2356,14 +2319,14 @@ function ObjectFieldTemplate(props) {
2356
2319
  return /*#__PURE__*/React__default["default"].createElement("fieldset", {
2357
2320
  id: idSchema.$id
2358
2321
  }, (options.title || title) && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
2359
- id: idSchema.$id + "__title",
2322
+ id: utils.titleId(idSchema),
2360
2323
  title: options.title || title,
2361
2324
  required: required,
2362
2325
  schema: schema,
2363
2326
  uiSchema: uiSchema,
2364
2327
  registry: registry
2365
2328
  }), (options.description || description) && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
2366
- id: idSchema.$id + "__description",
2329
+ id: utils.descriptionId(idSchema),
2367
2330
  description: options.description || description,
2368
2331
  schema: schema,
2369
2332
  uiSchema: uiSchema,
@@ -2417,6 +2380,7 @@ function UnsupportedField(props) {
2417
2380
  function WrapIfAdditionalTemplate(props) {
2418
2381
  var id = props.id,
2419
2382
  classNames = props.classNames,
2383
+ style = props.style,
2420
2384
  disabled = props.disabled,
2421
2385
  label = props.label,
2422
2386
  onKeyChange = props.onKeyChange,
@@ -2433,11 +2397,13 @@ function WrapIfAdditionalTemplate(props) {
2433
2397
  var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
2434
2398
  if (!additional) {
2435
2399
  return /*#__PURE__*/React__default["default"].createElement("div", {
2436
- className: classNames
2400
+ className: classNames,
2401
+ style: style
2437
2402
  }, children);
2438
2403
  }
2439
2404
  return /*#__PURE__*/React__default["default"].createElement("div", {
2440
- className: classNames
2405
+ className: classNames,
2406
+ style: style
2441
2407
  }, /*#__PURE__*/React__default["default"].createElement("div", {
2442
2408
  className: "row"
2443
2409
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -2581,7 +2547,8 @@ function DateElement(_ref) {
2581
2547
  onBlur: onBlur,
2582
2548
  onFocus: onFocus,
2583
2549
  registry: registry,
2584
- label: ""
2550
+ label: "",
2551
+ "aria-describedby": utils.ariaDescribedByIds(rootId)
2585
2552
  });
2586
2553
  }
2587
2554
  /** The `AltDateWidget` is an alternative widget for rendering date properties.
@@ -2719,7 +2686,7 @@ function CheckboxWidget(_ref) {
2719
2686
  return /*#__PURE__*/React__default["default"].createElement("div", {
2720
2687
  className: "checkbox " + (disabled || readonly ? "disabled" : "")
2721
2688
  }, schema.description && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
2722
- id: id + "__description",
2689
+ id: utils.descriptionId(id),
2723
2690
  description: schema.description,
2724
2691
  schema: schema,
2725
2692
  uiSchema: uiSchema,
@@ -2734,24 +2701,11 @@ function CheckboxWidget(_ref) {
2734
2701
  autoFocus: autofocus,
2735
2702
  onChange: handleChange,
2736
2703
  onBlur: handleBlur,
2737
- onFocus: handleFocus
2704
+ onFocus: handleFocus,
2705
+ "aria-describedby": utils.ariaDescribedByIds(id)
2738
2706
  }), /*#__PURE__*/React__default["default"].createElement("span", null, label)));
2739
2707
  }
2740
2708
 
2741
- function selectValue(value, selected, all) {
2742
- var at = all.indexOf(value);
2743
- var updated = selected.slice(0, at).concat(value, selected.slice(at));
2744
- // As inserting values at predefined index positions doesn't work with empty
2745
- // arrays, we need to reorder the updated selection to match the initial order
2746
- return updated.sort(function (a, b) {
2747
- return Number(all.indexOf(a) > all.indexOf(b));
2748
- });
2749
- }
2750
- function deselectValue(value, selected) {
2751
- return selected.filter(function (v) {
2752
- return v !== value;
2753
- });
2754
- }
2755
2709
  /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
2756
2710
  * It is typically used to represent an array of enums.
2757
2711
  *
@@ -2770,32 +2724,30 @@ function CheckboxesWidget(_ref) {
2770
2724
  autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
2771
2725
  readonly = _ref.readonly,
2772
2726
  onChange = _ref.onChange;
2727
+ var checkboxesValues = Array.isArray(value) ? value : [value];
2773
2728
  return /*#__PURE__*/React__default["default"].createElement("div", {
2774
2729
  className: "checkboxes",
2775
2730
  id: id
2776
2731
  }, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
2777
- var checked = value.indexOf(option.value) !== -1;
2732
+ var checked = checkboxesValues.includes(option.value);
2778
2733
  var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) != -1;
2779
2734
  var disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
2780
2735
  var handleChange = function handleChange(event) {
2781
- var all = enumOptions.map(function (_ref2) {
2782
- var value = _ref2.value;
2783
- return value;
2784
- });
2785
2736
  if (event.target.checked) {
2786
- onChange(selectValue(option.value, value, all));
2737
+ onChange(utils.enumOptionsSelectValue(option.value, checkboxesValues, enumOptions));
2787
2738
  } else {
2788
- onChange(deselectValue(option.value, value));
2739
+ onChange(utils.enumOptionsDeselectValue(option.value, checkboxesValues));
2789
2740
  }
2790
2741
  };
2791
2742
  var checkbox = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
2792
2743
  type: "checkbox",
2793
- id: id + "-" + option.value,
2744
+ id: utils.optionId(id, option),
2794
2745
  name: id,
2795
2746
  checked: checked,
2796
2747
  disabled: disabled || itemDisabled || readonly,
2797
2748
  autoFocus: autofocus && index === 0,
2798
- onChange: handleChange
2749
+ onChange: handleChange,
2750
+ "aria-describedby": utils.ariaDescribedByIds(id)
2799
2751
  }), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
2800
2752
  return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
2801
2753
  key: option.value,
@@ -2991,7 +2943,8 @@ function FileWidget(_ref2) {
2991
2943
  defaultValue: "",
2992
2944
  autoFocus: autofocus,
2993
2945
  multiple: multiple,
2994
- accept: options.accept ? String(options.accept) : undefined
2946
+ accept: options.accept ? String(options.accept) : undefined,
2947
+ "aria-describedby": utils.ariaDescribedByIds(id)
2995
2948
  })), /*#__PURE__*/React__default["default"].createElement(FilesInfo, {
2996
2949
  filesInfo: filesInfo
2997
2950
  }));
@@ -3068,7 +3021,7 @@ function RadioWidget(_ref) {
3068
3021
  };
3069
3022
  var radio = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
3070
3023
  type: "radio",
3071
- id: id + "-" + option.value,
3024
+ id: utils.optionId(id, option),
3072
3025
  checked: checked,
3073
3026
  name: name,
3074
3027
  required: required,
@@ -3077,7 +3030,8 @@ function RadioWidget(_ref) {
3077
3030
  autoFocus: autofocus && i === 0,
3078
3031
  onChange: handleChange,
3079
3032
  onBlur: handleBlur,
3080
- onFocus: handleFocus
3033
+ onFocus: handleFocus,
3034
+ "aria-describedby": utils.ariaDescribedByIds(id)
3081
3035
  }), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
3082
3036
  return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
3083
3037
  key: option.value,
@@ -3163,7 +3117,8 @@ function SelectWidget(_ref) {
3163
3117
  autoFocus: autofocus,
3164
3118
  onBlur: handleBlur,
3165
3119
  onFocus: handleFocus,
3166
- onChange: handleChange
3120
+ onChange: handleChange,
3121
+ "aria-describedby": utils.ariaDescribedByIds(id)
3167
3122
  }, !multiple && schema["default"] === undefined && /*#__PURE__*/React__default["default"].createElement("option", {
3168
3123
  value: ""
3169
3124
  }, placeholder), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
@@ -3221,7 +3176,8 @@ function TextareaWidget(_ref) {
3221
3176
  rows: options.rows,
3222
3177
  onBlur: handleBlur,
3223
3178
  onFocus: handleFocus,
3224
- onChange: handleChange
3179
+ onChange: handleChange,
3180
+ "aria-describedby": utils.ariaDescribedByIds(id)
3225
3181
  });
3226
3182
  }
3227
3183
  TextareaWidget.defaultProps = {
@@ -3358,7 +3314,7 @@ var Form = /*#__PURE__*/function (_Component) {
3358
3314
  var formValue = get__default["default"](formData, path);
3359
3315
  // adds path to fieldNames if it points to a value
3360
3316
  // or an empty object/array
3361
- if (typeof formValue !== "object" || _isEmpty__default["default"](formValue)) {
3317
+ if (typeof formValue !== "object" || isEmpty__default["default"](formValue)) {
3362
3318
  acc.push(path);
3363
3319
  }
3364
3320
  });
@@ -3794,9 +3750,9 @@ function withTheme(themeProps) {
3794
3750
  widgets = _ref.widgets,
3795
3751
  templates = _ref.templates,
3796
3752
  directProps = _objectWithoutPropertiesLoose(_ref, _excluded);
3797
- fields = _extends({}, themeProps.fields, fields);
3798
- widgets = _extends({}, themeProps.widgets, widgets);
3799
- templates = _extends({}, themeProps.templates, templates, {
3753
+ fields = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.fields, fields);
3754
+ widgets = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.widgets, widgets);
3755
+ templates = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.templates, templates, {
3800
3756
  ButtonTemplates: _extends({}, themeProps === null || themeProps === void 0 ? void 0 : (_themeProps$templates = themeProps.templates) === null || _themeProps$templates === void 0 ? void 0 : _themeProps$templates.ButtonTemplates, (_templates = templates) === null || _templates === void 0 ? void 0 : _templates.ButtonTemplates)
3801
3757
  });
3802
3758
  return /*#__PURE__*/React__default["default"].createElement(Form, _extends({}, themeProps, directProps, {