@rjsf/core 5.0.0-beta.15 → 5.0.0-beta.17

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,13 +1,13 @@
1
1
  import React, { Component, useState, useCallback, useEffect, useReducer, useMemo, forwardRef } from 'react';
2
- import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, isCustomWidget, getWidget, optionsList, guessType, deepEquals, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, mergeObjects, getSchemaType, ID_KEY, hasWidget, getInputProps, getSubmitButtonOptions, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, utcToLocal, localToUTC, dataURItoBlob, processSelectValue, createSchemaUtils, shouldRender, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
2
+ import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, isCustomWidget, getWidget, optionsList, guessType, deepEquals, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, processSelectValue, createSchemaUtils, shouldRender, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
3
3
  import get from 'lodash-es/get';
4
4
  import _isEmpty from 'lodash-es/isEmpty';
5
5
  import _pick from 'lodash-es/pick';
6
6
  import isObject from 'lodash-es/isObject';
7
7
  import set from 'lodash-es/set';
8
8
  import { nanoid } from 'nanoid';
9
- import unset from 'lodash-es/unset';
10
9
  import has from 'lodash-es/has';
10
+ import unset from 'lodash-es/unset';
11
11
  import omit from 'lodash-es/omit';
12
12
 
13
13
  function _defineProperties(target, props) {
@@ -16,7 +16,7 @@ function _defineProperties(target, props) {
16
16
  descriptor.enumerable = descriptor.enumerable || false;
17
17
  descriptor.configurable = true;
18
18
  if ("value" in descriptor) descriptor.writable = true;
19
- Object.defineProperty(target, descriptor.key, descriptor);
19
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
20
20
  }
21
21
  }
22
22
  function _createClass(Constructor, protoProps, staticProps) {
@@ -96,6 +96,20 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
96
96
  }
97
97
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
98
  }
99
+ function _toPrimitive(input, hint) {
100
+ if (typeof input !== "object" || input === null) return input;
101
+ var prim = input[Symbol.toPrimitive];
102
+ if (prim !== undefined) {
103
+ var res = prim.call(input, hint || "default");
104
+ if (typeof res !== "object") return res;
105
+ throw new TypeError("@@toPrimitive must return a primitive value.");
106
+ }
107
+ return (hint === "string" ? String : Number)(input);
108
+ }
109
+ function _toPropertyKey(arg) {
110
+ var key = _toPrimitive(arg, "string");
111
+ return typeof key === "symbol" ? key : String(key);
112
+ }
99
113
 
100
114
  var _excluded$9 = ["widget"],
101
115
  _excluded2 = ["widget"],
@@ -155,42 +169,11 @@ var ArrayField = /*#__PURE__*/function (_Component) {
155
169
  return schemaUtils.getDefaultFormState(itemSchema);
156
170
  };
157
171
  _this.onAddClick = function (event) {
158
- if (event) {
159
- event.preventDefault();
160
- }
161
- var onChange = _this.props.onChange;
162
- var keyedFormData = _this.state.keyedFormData;
163
- var newKeyedFormDataRow = {
164
- key: generateRowId(),
165
- item: _this._getNewFormDataRow()
166
- };
167
- var newKeyedFormData = [].concat(keyedFormData, [newKeyedFormDataRow]);
168
- _this.setState({
169
- keyedFormData: newKeyedFormData,
170
- updatedKeyedFormData: true
171
- }, function () {
172
- return onChange(keyedToPlainFormData(newKeyedFormData));
173
- });
172
+ _this._handleAddClick(event);
174
173
  };
175
174
  _this.onAddIndexClick = function (index) {
176
175
  return function (event) {
177
- if (event) {
178
- event.preventDefault();
179
- }
180
- var onChange = _this.props.onChange;
181
- var keyedFormData = _this.state.keyedFormData;
182
- var newKeyedFormDataRow = {
183
- key: generateRowId(),
184
- item: _this._getNewFormDataRow()
185
- };
186
- var newKeyedFormData = [].concat(keyedFormData);
187
- newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
188
- _this.setState({
189
- keyedFormData: newKeyedFormData,
190
- updatedKeyedFormData: true
191
- }, function () {
192
- return onChange(keyedToPlainFormData(newKeyedFormData));
193
- });
176
+ _this._handleAddClick(event, index);
194
177
  };
195
178
  };
196
179
  _this.onDropIndexClick = function (index) {
@@ -369,6 +352,42 @@ var ArrayField = /*#__PURE__*/function (_Component) {
369
352
  /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
370
353
  * that the schema is fixed and allows additional items.
371
354
  */;
355
+ /** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
356
+ * either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
357
+ * the state, and then returning `onChange()` with the plain form data converted from the keyed data
358
+ *
359
+ * @param event - The event for the click
360
+ * @param [index] - The optional index at which to add the new data
361
+ */
362
+ _proto._handleAddClick = function _handleAddClick(event, index) {
363
+ if (event) {
364
+ event.preventDefault();
365
+ }
366
+ var onChange = this.props.onChange;
367
+ var keyedFormData = this.state.keyedFormData;
368
+ var newKeyedFormDataRow = {
369
+ key: generateRowId(),
370
+ item: this._getNewFormDataRow()
371
+ };
372
+ var newKeyedFormData = [].concat(keyedFormData);
373
+ if (index !== undefined) {
374
+ newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
375
+ } else {
376
+ newKeyedFormData.push(newKeyedFormDataRow);
377
+ }
378
+ this.setState({
379
+ keyedFormData: newKeyedFormData,
380
+ updatedKeyedFormData: true
381
+ }, function () {
382
+ return onChange(keyedToPlainFormData(newKeyedFormData));
383
+ });
384
+ }
385
+ /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
386
+ * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
387
+ * keyed data
388
+ *
389
+ * @param event - The event for the click
390
+ */;
372
391
  /** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
373
392
  */
374
393
  _proto.render = function render() {
@@ -437,8 +456,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
437
456
  var _schemaItems = isObject(schema.items) ? schema.items : {};
438
457
  var itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
439
458
  var formData = keyedToPlainFormData(this.state.keyedFormData);
459
+ var canAdd = this.canAddItem(formData);
440
460
  var arrayProps = {
441
- canAdd: this.canAddItem(formData),
461
+ canAdd: canAdd,
442
462
  items: keyedFormData.map(function (keyedItem, index) {
443
463
  var key = keyedItem.key,
444
464
  item = keyedItem.item;
@@ -452,6 +472,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
452
472
  key: key,
453
473
  index: index,
454
474
  name: name && name + "-" + index,
475
+ canAdd: canAdd,
455
476
  canMoveUp: index > 0,
456
477
  canMoveDown: index < formData.length - 1,
457
478
  itemSchema: itemSchema,
@@ -462,7 +483,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
462
483
  autofocus: autofocus && index === 0,
463
484
  onBlur: onBlur,
464
485
  onFocus: onFocus,
465
- rawErrors: rawErrors
486
+ rawErrors: rawErrors,
487
+ totalItems: keyedFormData.length
466
488
  });
467
489
  }),
468
490
  className: "field field-array field-array-of-" + itemsSchema.type,
@@ -514,7 +536,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
514
536
  options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
515
537
  var Widget = getWidget(schema, widget, widgets);
516
538
  return /*#__PURE__*/React.createElement(Widget, {
517
- id: idSchema && idSchema.$id,
539
+ id: idSchema.$id,
518
540
  multiple: true,
519
541
  onChange: this.onSelectChange,
520
542
  onBlur: onBlur,
@@ -570,7 +592,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
570
592
  options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
571
593
  var Widget = getWidget(schema, widget, widgets);
572
594
  return /*#__PURE__*/React.createElement(Widget, {
573
- id: idSchema && idSchema.$id,
595
+ id: idSchema.$id,
574
596
  multiple: true,
575
597
  onChange: this.onSelectChange,
576
598
  onBlur: onBlur,
@@ -624,7 +646,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
624
646
  var Widget = getWidget(schema, widget, widgets);
625
647
  return /*#__PURE__*/React.createElement(Widget, {
626
648
  options: options,
627
- id: idSchema && idSchema.$id,
649
+ id: idSchema.$id,
628
650
  multiple: true,
629
651
  onChange: this.onSelectChange,
630
652
  onBlur: onBlur,
@@ -689,8 +711,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
689
711
  items = items.concat(new Array(itemSchemas.length - items.length));
690
712
  }
691
713
  // These are the props passed into the render function
714
+ var canAdd = this.canAddItem(items) && !!additionalSchema;
692
715
  var arrayProps = {
693
- canAdd: this.canAddItem(items) && !!additionalSchema,
716
+ canAdd: canAdd,
694
717
  className: "field field-array field-array-fixed-items",
695
718
  disabled: disabled,
696
719
  idSchema: idSchema,
@@ -710,6 +733,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
710
733
  key: key,
711
734
  index: index,
712
735
  name: name && name + "-" + index,
736
+ canAdd: canAdd,
713
737
  canRemove: additional,
714
738
  canMoveUp: index >= itemSchemas.length + 1,
715
739
  canMoveDown: additional && index < items.length - 1,
@@ -721,7 +745,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
721
745
  autofocus: autofocus && index === 0,
722
746
  onBlur: onBlur,
723
747
  onFocus: onFocus,
724
- rawErrors: rawErrors
748
+ rawErrors: rawErrors,
749
+ totalItems: keyedFormData.length
725
750
  });
726
751
  }),
727
752
  onAddClick: this.onAddClick,
@@ -746,6 +771,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
746
771
  var key = props.key,
747
772
  index = props.index,
748
773
  name = props.name,
774
+ canAdd = props.canAdd,
749
775
  _props$canRemove = props.canRemove,
750
776
  canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
751
777
  _props$canMoveUp = props.canMoveUp,
@@ -760,7 +786,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
760
786
  autofocus = props.autofocus,
761
787
  onBlur = props.onBlur,
762
788
  onFocus = props.onFocus,
763
- rawErrors = props.rawErrors;
789
+ rawErrors = props.rawErrors,
790
+ totalItems = props.totalItems;
764
791
  var _this$props13 = this.props,
765
792
  disabled = _this$props13.disabled,
766
793
  hideError = _this$props13.hideError,
@@ -813,11 +840,13 @@ var ArrayField = /*#__PURE__*/function (_Component) {
813
840
  }),
814
841
  className: "array-item",
815
842
  disabled: disabled,
843
+ canAdd: canAdd,
816
844
  hasToolbar: has.toolbar,
817
845
  hasMoveUp: has.moveUp,
818
846
  hasMoveDown: has.moveDown,
819
847
  hasRemove: has.remove,
820
848
  index: index,
849
+ totalItems: totalItems,
821
850
  key: key,
822
851
  onAddIndexClick: this.onAddIndexClick,
823
852
  onDropIndexClick: this.onDropIndexClick,
@@ -910,7 +939,7 @@ function BooleanField(props) {
910
939
  }),
911
940
  schema: schema,
912
941
  uiSchema: uiSchema,
913
- id: idSchema && idSchema.$id,
942
+ id: idSchema.$id,
914
943
  onChange: onChange,
915
944
  onFocus: onFocus,
916
945
  onBlur: onBlur,
@@ -962,7 +991,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
962
991
  var _option = _step.value;
963
992
  if (_option.properties) {
964
993
  for (var key in _option.properties) {
965
- if (key in newFormData) {
994
+ if (has(newFormData, key)) {
966
995
  unset(newFormData, key);
967
996
  }
968
997
  }
@@ -1260,7 +1289,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
1260
1289
  duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? "-" : _getUiOptions$duplica;
1261
1290
  var index = 0;
1262
1291
  var newKey = preferredKey;
1263
- while (newKey in formData) {
1292
+ while (has(formData, newKey)) {
1264
1293
  newKey = "" + preferredKey + duplicateKeySuffixSeparator + ++index;
1265
1294
  }
1266
1295
  return newKey;
@@ -1571,10 +1600,10 @@ function SchemaFieldRender(props) {
1571
1600
  var _ref = errorSchema || {},
1572
1601
  __errors = _ref.__errors,
1573
1602
  fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1574
- // See #439: uiSchema: Don't pass consumed class names to child components
1575
- var fieldUiSchema = omit(uiSchema, ["ui:classNames", "classNames"]);
1576
- if ("ui:options" in fieldUiSchema) {
1577
- fieldUiSchema["ui:options"] = omit(fieldUiSchema["ui:options"], ["classNames"]);
1603
+ // See #439: uiSchema: Don't pass consumed class names or style to child components
1604
+ var fieldUiSchema = omit(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
1605
+ if (UI_OPTIONS_KEY in fieldUiSchema) {
1606
+ fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], ["classNames", "style"]);
1578
1607
  }
1579
1608
  var field = /*#__PURE__*/React.createElement(FieldComponent, _extends({}, props, {
1580
1609
  onChange: handleFieldComponentChange,
@@ -1631,7 +1660,7 @@ function SchemaFieldRender(props) {
1631
1660
  });
1632
1661
  var fieldProps = {
1633
1662
  description: /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
1634
- id: id + "__description",
1663
+ id: descriptionId(id),
1635
1664
  description: description,
1636
1665
  schema: schema,
1637
1666
  uiSchema: uiSchema,
@@ -1654,6 +1683,7 @@ function SchemaFieldRender(props) {
1654
1683
  hideError: hideError,
1655
1684
  displayLabel: displayLabel,
1656
1685
  classNames: classNames.join(" ").trim(),
1686
+ style: uiOptions.style,
1657
1687
  formContext: formContext,
1658
1688
  formData: formData,
1659
1689
  schema: schema,
@@ -1770,7 +1800,7 @@ function StringField(props) {
1770
1800
  }),
1771
1801
  schema: schema,
1772
1802
  uiSchema: uiSchema,
1773
- id: idSchema && idSchema.$id,
1803
+ id: idSchema.$id,
1774
1804
  label: title === undefined ? name : title,
1775
1805
  value: formData,
1776
1806
  onChange: onChange,
@@ -1836,9 +1866,8 @@ function ArrayFieldDescriptionTemplate(props) {
1836
1866
  return null;
1837
1867
  }
1838
1868
  var DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, options);
1839
- var id = idSchema.$id + "__description";
1840
1869
  return /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
1841
- id: id,
1870
+ id: descriptionId(idSchema),
1842
1871
  description: description,
1843
1872
  schema: schema,
1844
1873
  uiSchema: uiSchema,
@@ -1890,17 +1919,20 @@ function ArrayFieldItemTemplate(props) {
1890
1919
  style: btnStyle,
1891
1920
  disabled: disabled || readonly || !hasMoveUp,
1892
1921
  onClick: onReorderClick(index, index - 1),
1893
- uiSchema: uiSchema
1922
+ uiSchema: uiSchema,
1923
+ registry: registry
1894
1924
  }), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React.createElement(MoveDownButton, {
1895
1925
  style: btnStyle,
1896
1926
  disabled: disabled || readonly || !hasMoveDown,
1897
1927
  onClick: onReorderClick(index, index + 1),
1898
- uiSchema: uiSchema
1928
+ uiSchema: uiSchema,
1929
+ registry: registry
1899
1930
  }), hasRemove && /*#__PURE__*/React.createElement(RemoveButton, {
1900
1931
  style: btnStyle,
1901
1932
  disabled: disabled || readonly,
1902
1933
  onClick: onDropIndexClick(index),
1903
- uiSchema: uiSchema
1934
+ uiSchema: uiSchema,
1935
+ registry: registry
1904
1936
  }))));
1905
1937
  }
1906
1938
 
@@ -1956,7 +1988,8 @@ function ArrayFieldTemplate(props) {
1956
1988
  className: "array-item-add",
1957
1989
  onClick: onAddClick,
1958
1990
  disabled: disabled || readonly,
1959
- uiSchema: uiSchema
1991
+ uiSchema: uiSchema,
1992
+ registry: registry
1960
1993
  }));
1961
1994
  }
1962
1995
 
@@ -1979,9 +2012,8 @@ function ArrayFieldTitleTemplate(props) {
1979
2012
  return null;
1980
2013
  }
1981
2014
  var TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, options);
1982
- var id = idSchema.$id + "__title";
1983
2015
  return /*#__PURE__*/React.createElement(TitleFieldTemplate, {
1984
- id: id,
2016
+ id: titleId(idSchema),
1985
2017
  title: title,
1986
2018
  required: required,
1987
2019
  schema: schema,
@@ -2044,13 +2076,14 @@ function BaseInputTemplate(props) {
2044
2076
  autoFocus: autofocus,
2045
2077
  value: inputValue
2046
2078
  }, inputProps, {
2047
- list: schema.examples ? "examples_" + id : undefined,
2079
+ list: schema.examples ? examplesId(id) : undefined,
2048
2080
  onChange: _onChange,
2049
2081
  onBlur: _onBlur,
2050
- onFocus: _onFocus
2082
+ onFocus: _onFocus,
2083
+ "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
2051
2084
  })), Array.isArray(schema.examples) && /*#__PURE__*/React.createElement("datalist", {
2052
2085
  key: "datalist_" + id,
2053
- id: "examples_" + id
2086
+ id: examplesId(id)
2054
2087
  }, [].concat(new Set(schema.examples.concat(schema["default"] ? [schema["default"]] : []))).map(function (example) {
2055
2088
  return /*#__PURE__*/React.createElement("option", {
2056
2089
  key: example,
@@ -2078,7 +2111,7 @@ function SubmitButton(_ref) {
2078
2111
  }), submitText));
2079
2112
  }
2080
2113
 
2081
- var _excluded$2 = ["iconType", "icon", "className", "uiSchema"];
2114
+ var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
2082
2115
  function IconButton(props) {
2083
2116
  var _props$iconType = props.iconType,
2084
2117
  iconType = _props$iconType === void 0 ? "default" : _props$iconType,
@@ -2123,7 +2156,8 @@ function RemoveButton(props) {
2123
2156
  function AddButton(_ref) {
2124
2157
  var className = _ref.className,
2125
2158
  onClick = _ref.onClick,
2126
- disabled = _ref.disabled;
2159
+ disabled = _ref.disabled,
2160
+ registry = _ref.registry;
2127
2161
  return /*#__PURE__*/React.createElement("div", {
2128
2162
  className: "row"
2129
2163
  }, /*#__PURE__*/React.createElement("p", {
@@ -2134,7 +2168,8 @@ function AddButton(_ref) {
2134
2168
  className: "btn-add col-xs-12",
2135
2169
  title: "Add",
2136
2170
  onClick: onClick,
2137
- disabled: disabled
2171
+ disabled: disabled,
2172
+ registry: registry
2138
2173
  })));
2139
2174
  }
2140
2175
 
@@ -2255,7 +2290,7 @@ function FieldErrorTemplate(props) {
2255
2290
  if (errors.length === 0) {
2256
2291
  return null;
2257
2292
  }
2258
- var id = idSchema.$id + "__error";
2293
+ var id = errorId(idSchema);
2259
2294
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("ul", {
2260
2295
  id: id,
2261
2296
  className: "error-detail bs-callout bs-callout-info"
@@ -2279,7 +2314,7 @@ function FieldHelpTemplate(props) {
2279
2314
  if (!help) {
2280
2315
  return null;
2281
2316
  }
2282
- var id = idSchema.$id + "__help";
2317
+ var id = helpId(idSchema);
2283
2318
  if (typeof help === "string") {
2284
2319
  return /*#__PURE__*/React.createElement("p", {
2285
2320
  id: id,
@@ -2319,14 +2354,14 @@ function ObjectFieldTemplate(props) {
2319
2354
  return /*#__PURE__*/React.createElement("fieldset", {
2320
2355
  id: idSchema.$id
2321
2356
  }, (options.title || title) && /*#__PURE__*/React.createElement(TitleFieldTemplate, {
2322
- id: idSchema.$id + "__title",
2357
+ id: titleId(idSchema),
2323
2358
  title: options.title || title,
2324
2359
  required: required,
2325
2360
  schema: schema,
2326
2361
  uiSchema: uiSchema,
2327
2362
  registry: registry
2328
2363
  }), (options.description || description) && /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
2329
- id: idSchema.$id + "__description",
2364
+ id: descriptionId(idSchema),
2330
2365
  description: options.description || description,
2331
2366
  schema: schema,
2332
2367
  uiSchema: uiSchema,
@@ -2337,7 +2372,8 @@ function ObjectFieldTemplate(props) {
2337
2372
  className: "object-property-expand",
2338
2373
  onClick: onAddClick(schema),
2339
2374
  disabled: disabled || readonly,
2340
- uiSchema: uiSchema
2375
+ uiSchema: uiSchema,
2376
+ registry: registry
2341
2377
  }));
2342
2378
  }
2343
2379
 
@@ -2379,6 +2415,7 @@ function UnsupportedField(props) {
2379
2415
  function WrapIfAdditionalTemplate(props) {
2380
2416
  var id = props.id,
2381
2417
  classNames = props.classNames,
2418
+ style = props.style,
2382
2419
  disabled = props.disabled,
2383
2420
  label = props.label,
2384
2421
  onKeyChange = props.onKeyChange,
@@ -2395,11 +2432,13 @@ function WrapIfAdditionalTemplate(props) {
2395
2432
  var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
2396
2433
  if (!additional) {
2397
2434
  return /*#__PURE__*/React.createElement("div", {
2398
- className: classNames
2435
+ className: classNames,
2436
+ style: style
2399
2437
  }, children);
2400
2438
  }
2401
2439
  return /*#__PURE__*/React.createElement("div", {
2402
- className: classNames
2440
+ className: classNames,
2441
+ style: style
2403
2442
  }, /*#__PURE__*/React.createElement("div", {
2404
2443
  className: "row"
2405
2444
  }, /*#__PURE__*/React.createElement("div", {
@@ -2429,7 +2468,8 @@ function WrapIfAdditionalTemplate(props) {
2429
2468
  },
2430
2469
  disabled: disabled || readonly,
2431
2470
  onClick: onDropPropertyClick(label),
2432
- uiSchema: uiSchema
2471
+ uiSchema: uiSchema,
2472
+ registry: registry
2433
2473
  }))));
2434
2474
  }
2435
2475
 
@@ -2542,7 +2582,8 @@ function DateElement(_ref) {
2542
2582
  onBlur: onBlur,
2543
2583
  onFocus: onFocus,
2544
2584
  registry: registry,
2545
- label: ""
2585
+ label: "",
2586
+ "aria-describedby": ariaDescribedByIds(rootId)
2546
2587
  });
2547
2588
  }
2548
2589
  /** The `AltDateWidget` is an alternative widget for rendering date properties.
@@ -2680,7 +2721,7 @@ function CheckboxWidget(_ref) {
2680
2721
  return /*#__PURE__*/React.createElement("div", {
2681
2722
  className: "checkbox " + (disabled || readonly ? "disabled" : "")
2682
2723
  }, schema.description && /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
2683
- id: id + "__description",
2724
+ id: descriptionId(id),
2684
2725
  description: schema.description,
2685
2726
  schema: schema,
2686
2727
  uiSchema: uiSchema,
@@ -2695,24 +2736,11 @@ function CheckboxWidget(_ref) {
2695
2736
  autoFocus: autofocus,
2696
2737
  onChange: handleChange,
2697
2738
  onBlur: handleBlur,
2698
- onFocus: handleFocus
2739
+ onFocus: handleFocus,
2740
+ "aria-describedby": ariaDescribedByIds(id)
2699
2741
  }), /*#__PURE__*/React.createElement("span", null, label)));
2700
2742
  }
2701
2743
 
2702
- function selectValue(value, selected, all) {
2703
- var at = all.indexOf(value);
2704
- var updated = selected.slice(0, at).concat(value, selected.slice(at));
2705
- // As inserting values at predefined index positions doesn't work with empty
2706
- // arrays, we need to reorder the updated selection to match the initial order
2707
- return updated.sort(function (a, b) {
2708
- return Number(all.indexOf(a) > all.indexOf(b));
2709
- });
2710
- }
2711
- function deselectValue(value, selected) {
2712
- return selected.filter(function (v) {
2713
- return v !== value;
2714
- });
2715
- }
2716
2744
  /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
2717
2745
  * It is typically used to represent an array of enums.
2718
2746
  *
@@ -2731,32 +2759,30 @@ function CheckboxesWidget(_ref) {
2731
2759
  autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
2732
2760
  readonly = _ref.readonly,
2733
2761
  onChange = _ref.onChange;
2762
+ var checkboxesValues = Array.isArray(value) ? value : [value];
2734
2763
  return /*#__PURE__*/React.createElement("div", {
2735
2764
  className: "checkboxes",
2736
2765
  id: id
2737
2766
  }, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
2738
- var checked = value.indexOf(option.value) !== -1;
2767
+ var checked = checkboxesValues.includes(option.value);
2739
2768
  var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) != -1;
2740
2769
  var disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
2741
2770
  var handleChange = function handleChange(event) {
2742
- var all = enumOptions.map(function (_ref2) {
2743
- var value = _ref2.value;
2744
- return value;
2745
- });
2746
2771
  if (event.target.checked) {
2747
- onChange(selectValue(option.value, value, all));
2772
+ onChange(enumOptionsSelectValue(option.value, checkboxesValues, enumOptions));
2748
2773
  } else {
2749
- onChange(deselectValue(option.value, value));
2774
+ onChange(enumOptionsDeselectValue(option.value, checkboxesValues));
2750
2775
  }
2751
2776
  };
2752
2777
  var checkbox = /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("input", {
2753
2778
  type: "checkbox",
2754
- id: id + "-" + option.value,
2779
+ id: optionId(id, option),
2755
2780
  name: id,
2756
2781
  checked: checked,
2757
2782
  disabled: disabled || itemDisabled || readonly,
2758
2783
  autoFocus: autofocus && index === 0,
2759
- onChange: handleChange
2784
+ onChange: handleChange,
2785
+ "aria-describedby": ariaDescribedByIds(id)
2760
2786
  }), /*#__PURE__*/React.createElement("span", null, option.label));
2761
2787
  return inline ? /*#__PURE__*/React.createElement("label", {
2762
2788
  key: option.value,
@@ -2952,7 +2978,8 @@ function FileWidget(_ref2) {
2952
2978
  defaultValue: "",
2953
2979
  autoFocus: autofocus,
2954
2980
  multiple: multiple,
2955
- accept: options.accept ? String(options.accept) : undefined
2981
+ accept: options.accept ? String(options.accept) : undefined,
2982
+ "aria-describedby": ariaDescribedByIds(id)
2956
2983
  })), /*#__PURE__*/React.createElement(FilesInfo, {
2957
2984
  filesInfo: filesInfo
2958
2985
  }));
@@ -3029,7 +3056,7 @@ function RadioWidget(_ref) {
3029
3056
  };
3030
3057
  var radio = /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("input", {
3031
3058
  type: "radio",
3032
- id: id + "-" + option.value,
3059
+ id: optionId(id, option),
3033
3060
  checked: checked,
3034
3061
  name: name,
3035
3062
  required: required,
@@ -3038,7 +3065,8 @@ function RadioWidget(_ref) {
3038
3065
  autoFocus: autofocus && i === 0,
3039
3066
  onChange: handleChange,
3040
3067
  onBlur: handleBlur,
3041
- onFocus: handleFocus
3068
+ onFocus: handleFocus,
3069
+ "aria-describedby": ariaDescribedByIds(id)
3042
3070
  }), /*#__PURE__*/React.createElement("span", null, option.label));
3043
3071
  return inline ? /*#__PURE__*/React.createElement("label", {
3044
3072
  key: option.value,
@@ -3124,7 +3152,8 @@ function SelectWidget(_ref) {
3124
3152
  autoFocus: autofocus,
3125
3153
  onBlur: handleBlur,
3126
3154
  onFocus: handleFocus,
3127
- onChange: handleChange
3155
+ onChange: handleChange,
3156
+ "aria-describedby": ariaDescribedByIds(id)
3128
3157
  }, !multiple && schema["default"] === undefined && /*#__PURE__*/React.createElement("option", {
3129
3158
  value: ""
3130
3159
  }, placeholder), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
@@ -3182,7 +3211,8 @@ function TextareaWidget(_ref) {
3182
3211
  rows: options.rows,
3183
3212
  onBlur: handleBlur,
3184
3213
  onFocus: handleFocus,
3185
- onChange: handleChange
3214
+ onChange: handleChange,
3215
+ "aria-describedby": ariaDescribedByIds(id)
3186
3216
  });
3187
3217
  }
3188
3218
  TextareaWidget.defaultProps = {
@@ -3567,9 +3597,10 @@ var Form = /*#__PURE__*/function (_Component) {
3567
3597
  var schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
3568
3598
  var _this$props3 = this.props,
3569
3599
  customValidate = _this$props3.customValidate,
3570
- transformErrors = _this$props3.transformErrors;
3600
+ transformErrors = _this$props3.transformErrors,
3601
+ uiSchema = _this$props3.uiSchema;
3571
3602
  var resolvedSchema = schemaUtils.retrieveSchema(schema, formData);
3572
- return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors);
3603
+ return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors, uiSchema);
3573
3604
  }
3574
3605
  /** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */;
3575
3606
  _proto.renderErrors = function renderErrors(registry) {
@@ -3738,7 +3769,8 @@ var Form = /*#__PURE__*/function (_Component) {
3738
3769
  disabled: disabled,
3739
3770
  readonly: readonly
3740
3771
  }), children ? children : /*#__PURE__*/React.createElement(SubmitButton, {
3741
- uiSchema: uiSchema
3772
+ uiSchema: uiSchema,
3773
+ registry: registry
3742
3774
  }), showErrorList === "bottom" && this.renderErrors(registry));
3743
3775
  };
3744
3776
  return Form;