@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.cjs.development.js +141 -109
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +141 -109
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +144 -112
- package/dist/core.umd.development.js.map +1 -1
- package/dist/core.umd.production.min.js +1 -1
- package/dist/core.umd.production.min.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/package.json +16 -16
|
@@ -10,8 +10,8 @@ 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
13
|
var has = require('lodash/has');
|
|
14
|
+
var unset = require('lodash/unset');
|
|
15
15
|
var omit = require('lodash/omit');
|
|
16
16
|
|
|
17
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -22,8 +22,8 @@ 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
25
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
26
|
+
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
27
27
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
28
28
|
|
|
29
29
|
function _defineProperties(target, props) {
|
|
@@ -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) {
|
|
@@ -112,6 +112,20 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
112
112
|
}
|
|
113
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.");
|
|
114
114
|
}
|
|
115
|
+
function _toPrimitive(input, hint) {
|
|
116
|
+
if (typeof input !== "object" || input === null) return input;
|
|
117
|
+
var prim = input[Symbol.toPrimitive];
|
|
118
|
+
if (prim !== undefined) {
|
|
119
|
+
var res = prim.call(input, hint || "default");
|
|
120
|
+
if (typeof res !== "object") return res;
|
|
121
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
122
|
+
}
|
|
123
|
+
return (hint === "string" ? String : Number)(input);
|
|
124
|
+
}
|
|
125
|
+
function _toPropertyKey(arg) {
|
|
126
|
+
var key = _toPrimitive(arg, "string");
|
|
127
|
+
return typeof key === "symbol" ? key : String(key);
|
|
128
|
+
}
|
|
115
129
|
|
|
116
130
|
var _excluded$9 = ["widget"],
|
|
117
131
|
_excluded2 = ["widget"],
|
|
@@ -171,42 +185,11 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
171
185
|
return schemaUtils.getDefaultFormState(itemSchema);
|
|
172
186
|
};
|
|
173
187
|
_this.onAddClick = function (event) {
|
|
174
|
-
|
|
175
|
-
event.preventDefault();
|
|
176
|
-
}
|
|
177
|
-
var onChange = _this.props.onChange;
|
|
178
|
-
var keyedFormData = _this.state.keyedFormData;
|
|
179
|
-
var newKeyedFormDataRow = {
|
|
180
|
-
key: generateRowId(),
|
|
181
|
-
item: _this._getNewFormDataRow()
|
|
182
|
-
};
|
|
183
|
-
var newKeyedFormData = [].concat(keyedFormData, [newKeyedFormDataRow]);
|
|
184
|
-
_this.setState({
|
|
185
|
-
keyedFormData: newKeyedFormData,
|
|
186
|
-
updatedKeyedFormData: true
|
|
187
|
-
}, function () {
|
|
188
|
-
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
189
|
-
});
|
|
188
|
+
_this._handleAddClick(event);
|
|
190
189
|
};
|
|
191
190
|
_this.onAddIndexClick = function (index) {
|
|
192
191
|
return function (event) {
|
|
193
|
-
|
|
194
|
-
event.preventDefault();
|
|
195
|
-
}
|
|
196
|
-
var onChange = _this.props.onChange;
|
|
197
|
-
var keyedFormData = _this.state.keyedFormData;
|
|
198
|
-
var newKeyedFormDataRow = {
|
|
199
|
-
key: generateRowId(),
|
|
200
|
-
item: _this._getNewFormDataRow()
|
|
201
|
-
};
|
|
202
|
-
var newKeyedFormData = [].concat(keyedFormData);
|
|
203
|
-
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
204
|
-
_this.setState({
|
|
205
|
-
keyedFormData: newKeyedFormData,
|
|
206
|
-
updatedKeyedFormData: true
|
|
207
|
-
}, function () {
|
|
208
|
-
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
209
|
-
});
|
|
192
|
+
_this._handleAddClick(event, index);
|
|
210
193
|
};
|
|
211
194
|
};
|
|
212
195
|
_this.onDropIndexClick = function (index) {
|
|
@@ -385,6 +368,42 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
385
368
|
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
386
369
|
* that the schema is fixed and allows additional items.
|
|
387
370
|
*/;
|
|
371
|
+
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
372
|
+
* either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
|
|
373
|
+
* the state, and then returning `onChange()` with the plain form data converted from the keyed data
|
|
374
|
+
*
|
|
375
|
+
* @param event - The event for the click
|
|
376
|
+
* @param [index] - The optional index at which to add the new data
|
|
377
|
+
*/
|
|
378
|
+
_proto._handleAddClick = function _handleAddClick(event, index) {
|
|
379
|
+
if (event) {
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
}
|
|
382
|
+
var onChange = this.props.onChange;
|
|
383
|
+
var keyedFormData = this.state.keyedFormData;
|
|
384
|
+
var newKeyedFormDataRow = {
|
|
385
|
+
key: generateRowId(),
|
|
386
|
+
item: this._getNewFormDataRow()
|
|
387
|
+
};
|
|
388
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
389
|
+
if (index !== undefined) {
|
|
390
|
+
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
391
|
+
} else {
|
|
392
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
393
|
+
}
|
|
394
|
+
this.setState({
|
|
395
|
+
keyedFormData: newKeyedFormData,
|
|
396
|
+
updatedKeyedFormData: true
|
|
397
|
+
}, function () {
|
|
398
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
402
|
+
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
403
|
+
* keyed data
|
|
404
|
+
*
|
|
405
|
+
* @param event - The event for the click
|
|
406
|
+
*/;
|
|
388
407
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
389
408
|
*/
|
|
390
409
|
_proto.render = function render() {
|
|
@@ -453,8 +472,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
453
472
|
var _schemaItems = isObject__default["default"](schema.items) ? schema.items : {};
|
|
454
473
|
var itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
|
|
455
474
|
var formData = keyedToPlainFormData(this.state.keyedFormData);
|
|
475
|
+
var canAdd = this.canAddItem(formData);
|
|
456
476
|
var arrayProps = {
|
|
457
|
-
canAdd:
|
|
477
|
+
canAdd: canAdd,
|
|
458
478
|
items: keyedFormData.map(function (keyedItem, index) {
|
|
459
479
|
var key = keyedItem.key,
|
|
460
480
|
item = keyedItem.item;
|
|
@@ -468,6 +488,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
468
488
|
key: key,
|
|
469
489
|
index: index,
|
|
470
490
|
name: name && name + "-" + index,
|
|
491
|
+
canAdd: canAdd,
|
|
471
492
|
canMoveUp: index > 0,
|
|
472
493
|
canMoveDown: index < formData.length - 1,
|
|
473
494
|
itemSchema: itemSchema,
|
|
@@ -478,7 +499,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
478
499
|
autofocus: autofocus && index === 0,
|
|
479
500
|
onBlur: onBlur,
|
|
480
501
|
onFocus: onFocus,
|
|
481
|
-
rawErrors: rawErrors
|
|
502
|
+
rawErrors: rawErrors,
|
|
503
|
+
totalItems: keyedFormData.length
|
|
482
504
|
});
|
|
483
505
|
}),
|
|
484
506
|
className: "field field-array field-array-of-" + itemsSchema.type,
|
|
@@ -530,7 +552,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
530
552
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
531
553
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
532
554
|
return /*#__PURE__*/React__default["default"].createElement(Widget, {
|
|
533
|
-
id: idSchema
|
|
555
|
+
id: idSchema.$id,
|
|
534
556
|
multiple: true,
|
|
535
557
|
onChange: this.onSelectChange,
|
|
536
558
|
onBlur: onBlur,
|
|
@@ -586,7 +608,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
586
608
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
587
609
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
588
610
|
return /*#__PURE__*/React__default["default"].createElement(Widget, {
|
|
589
|
-
id: idSchema
|
|
611
|
+
id: idSchema.$id,
|
|
590
612
|
multiple: true,
|
|
591
613
|
onChange: this.onSelectChange,
|
|
592
614
|
onBlur: onBlur,
|
|
@@ -640,7 +662,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
640
662
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
641
663
|
return /*#__PURE__*/React__default["default"].createElement(Widget, {
|
|
642
664
|
options: options,
|
|
643
|
-
id: idSchema
|
|
665
|
+
id: idSchema.$id,
|
|
644
666
|
multiple: true,
|
|
645
667
|
onChange: this.onSelectChange,
|
|
646
668
|
onBlur: onBlur,
|
|
@@ -705,8 +727,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
705
727
|
items = items.concat(new Array(itemSchemas.length - items.length));
|
|
706
728
|
}
|
|
707
729
|
// These are the props passed into the render function
|
|
730
|
+
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
708
731
|
var arrayProps = {
|
|
709
|
-
canAdd:
|
|
732
|
+
canAdd: canAdd,
|
|
710
733
|
className: "field field-array field-array-fixed-items",
|
|
711
734
|
disabled: disabled,
|
|
712
735
|
idSchema: idSchema,
|
|
@@ -726,6 +749,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
726
749
|
key: key,
|
|
727
750
|
index: index,
|
|
728
751
|
name: name && name + "-" + index,
|
|
752
|
+
canAdd: canAdd,
|
|
729
753
|
canRemove: additional,
|
|
730
754
|
canMoveUp: index >= itemSchemas.length + 1,
|
|
731
755
|
canMoveDown: additional && index < items.length - 1,
|
|
@@ -737,7 +761,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
737
761
|
autofocus: autofocus && index === 0,
|
|
738
762
|
onBlur: onBlur,
|
|
739
763
|
onFocus: onFocus,
|
|
740
|
-
rawErrors: rawErrors
|
|
764
|
+
rawErrors: rawErrors,
|
|
765
|
+
totalItems: keyedFormData.length
|
|
741
766
|
});
|
|
742
767
|
}),
|
|
743
768
|
onAddClick: this.onAddClick,
|
|
@@ -762,6 +787,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
762
787
|
var key = props.key,
|
|
763
788
|
index = props.index,
|
|
764
789
|
name = props.name,
|
|
790
|
+
canAdd = props.canAdd,
|
|
765
791
|
_props$canRemove = props.canRemove,
|
|
766
792
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
767
793
|
_props$canMoveUp = props.canMoveUp,
|
|
@@ -776,7 +802,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
776
802
|
autofocus = props.autofocus,
|
|
777
803
|
onBlur = props.onBlur,
|
|
778
804
|
onFocus = props.onFocus,
|
|
779
|
-
rawErrors = props.rawErrors
|
|
805
|
+
rawErrors = props.rawErrors,
|
|
806
|
+
totalItems = props.totalItems;
|
|
780
807
|
var _this$props13 = this.props,
|
|
781
808
|
disabled = _this$props13.disabled,
|
|
782
809
|
hideError = _this$props13.hideError,
|
|
@@ -829,11 +856,13 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
829
856
|
}),
|
|
830
857
|
className: "array-item",
|
|
831
858
|
disabled: disabled,
|
|
859
|
+
canAdd: canAdd,
|
|
832
860
|
hasToolbar: has.toolbar,
|
|
833
861
|
hasMoveUp: has.moveUp,
|
|
834
862
|
hasMoveDown: has.moveDown,
|
|
835
863
|
hasRemove: has.remove,
|
|
836
864
|
index: index,
|
|
865
|
+
totalItems: totalItems,
|
|
837
866
|
key: key,
|
|
838
867
|
onAddIndexClick: this.onAddIndexClick,
|
|
839
868
|
onDropIndexClick: this.onDropIndexClick,
|
|
@@ -926,7 +955,7 @@ function BooleanField(props) {
|
|
|
926
955
|
}),
|
|
927
956
|
schema: schema,
|
|
928
957
|
uiSchema: uiSchema,
|
|
929
|
-
id: idSchema
|
|
958
|
+
id: idSchema.$id,
|
|
930
959
|
onChange: onChange,
|
|
931
960
|
onFocus: onFocus,
|
|
932
961
|
onBlur: onBlur,
|
|
@@ -978,7 +1007,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
978
1007
|
var _option = _step.value;
|
|
979
1008
|
if (_option.properties) {
|
|
980
1009
|
for (var key in _option.properties) {
|
|
981
|
-
if (key
|
|
1010
|
+
if (has__default["default"](newFormData, key)) {
|
|
982
1011
|
unset__default["default"](newFormData, key);
|
|
983
1012
|
}
|
|
984
1013
|
}
|
|
@@ -1276,7 +1305,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1276
1305
|
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? "-" : _getUiOptions$duplica;
|
|
1277
1306
|
var index = 0;
|
|
1278
1307
|
var newKey = preferredKey;
|
|
1279
|
-
while (newKey
|
|
1308
|
+
while (has__default["default"](formData, newKey)) {
|
|
1280
1309
|
newKey = "" + preferredKey + duplicateKeySuffixSeparator + ++index;
|
|
1281
1310
|
}
|
|
1282
1311
|
return newKey;
|
|
@@ -1587,10 +1616,10 @@ function SchemaFieldRender(props) {
|
|
|
1587
1616
|
var _ref = errorSchema || {},
|
|
1588
1617
|
__errors = _ref.__errors,
|
|
1589
1618
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1590
|
-
// See #439: uiSchema: Don't pass consumed class names to child components
|
|
1591
|
-
var fieldUiSchema = omit__default["default"](uiSchema, ["ui:classNames", "classNames"]);
|
|
1592
|
-
if (
|
|
1593
|
-
fieldUiSchema[
|
|
1619
|
+
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1620
|
+
var fieldUiSchema = omit__default["default"](uiSchema, ["ui:classNames", "classNames", "ui:style"]);
|
|
1621
|
+
if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1622
|
+
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], ["classNames", "style"]);
|
|
1594
1623
|
}
|
|
1595
1624
|
var field = /*#__PURE__*/React__default["default"].createElement(FieldComponent, _extends({}, props, {
|
|
1596
1625
|
onChange: handleFieldComponentChange,
|
|
@@ -1647,7 +1676,7 @@ function SchemaFieldRender(props) {
|
|
|
1647
1676
|
});
|
|
1648
1677
|
var fieldProps = {
|
|
1649
1678
|
description: /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
1650
|
-
id: id
|
|
1679
|
+
id: utils.descriptionId(id),
|
|
1651
1680
|
description: description,
|
|
1652
1681
|
schema: schema,
|
|
1653
1682
|
uiSchema: uiSchema,
|
|
@@ -1670,6 +1699,7 @@ function SchemaFieldRender(props) {
|
|
|
1670
1699
|
hideError: hideError,
|
|
1671
1700
|
displayLabel: displayLabel,
|
|
1672
1701
|
classNames: classNames.join(" ").trim(),
|
|
1702
|
+
style: uiOptions.style,
|
|
1673
1703
|
formContext: formContext,
|
|
1674
1704
|
formData: formData,
|
|
1675
1705
|
schema: schema,
|
|
@@ -1786,7 +1816,7 @@ function StringField(props) {
|
|
|
1786
1816
|
}),
|
|
1787
1817
|
schema: schema,
|
|
1788
1818
|
uiSchema: uiSchema,
|
|
1789
|
-
id: idSchema
|
|
1819
|
+
id: idSchema.$id,
|
|
1790
1820
|
label: title === undefined ? name : title,
|
|
1791
1821
|
value: formData,
|
|
1792
1822
|
onChange: onChange,
|
|
@@ -1852,9 +1882,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1852
1882
|
return null;
|
|
1853
1883
|
}
|
|
1854
1884
|
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, options);
|
|
1855
|
-
var id = idSchema.$id + "__description";
|
|
1856
1885
|
return /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
1857
|
-
id:
|
|
1886
|
+
id: utils.descriptionId(idSchema),
|
|
1858
1887
|
description: description,
|
|
1859
1888
|
schema: schema,
|
|
1860
1889
|
uiSchema: uiSchema,
|
|
@@ -1906,17 +1935,20 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1906
1935
|
style: btnStyle,
|
|
1907
1936
|
disabled: disabled || readonly || !hasMoveUp,
|
|
1908
1937
|
onClick: onReorderClick(index, index - 1),
|
|
1909
|
-
uiSchema: uiSchema
|
|
1938
|
+
uiSchema: uiSchema,
|
|
1939
|
+
registry: registry
|
|
1910
1940
|
}), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveDownButton, {
|
|
1911
1941
|
style: btnStyle,
|
|
1912
1942
|
disabled: disabled || readonly || !hasMoveDown,
|
|
1913
1943
|
onClick: onReorderClick(index, index + 1),
|
|
1914
|
-
uiSchema: uiSchema
|
|
1944
|
+
uiSchema: uiSchema,
|
|
1945
|
+
registry: registry
|
|
1915
1946
|
}), hasRemove && /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
1916
1947
|
style: btnStyle,
|
|
1917
1948
|
disabled: disabled || readonly,
|
|
1918
1949
|
onClick: onDropIndexClick(index),
|
|
1919
|
-
uiSchema: uiSchema
|
|
1950
|
+
uiSchema: uiSchema,
|
|
1951
|
+
registry: registry
|
|
1920
1952
|
}))));
|
|
1921
1953
|
}
|
|
1922
1954
|
|
|
@@ -1972,7 +2004,8 @@ function ArrayFieldTemplate(props) {
|
|
|
1972
2004
|
className: "array-item-add",
|
|
1973
2005
|
onClick: onAddClick,
|
|
1974
2006
|
disabled: disabled || readonly,
|
|
1975
|
-
uiSchema: uiSchema
|
|
2007
|
+
uiSchema: uiSchema,
|
|
2008
|
+
registry: registry
|
|
1976
2009
|
}));
|
|
1977
2010
|
}
|
|
1978
2011
|
|
|
@@ -1995,9 +2028,8 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
1995
2028
|
return null;
|
|
1996
2029
|
}
|
|
1997
2030
|
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, options);
|
|
1998
|
-
var id = idSchema.$id + "__title";
|
|
1999
2031
|
return /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
2000
|
-
id:
|
|
2032
|
+
id: utils.titleId(idSchema),
|
|
2001
2033
|
title: title,
|
|
2002
2034
|
required: required,
|
|
2003
2035
|
schema: schema,
|
|
@@ -2060,13 +2092,14 @@ function BaseInputTemplate(props) {
|
|
|
2060
2092
|
autoFocus: autofocus,
|
|
2061
2093
|
value: inputValue
|
|
2062
2094
|
}, inputProps, {
|
|
2063
|
-
list: schema.examples ?
|
|
2095
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
2064
2096
|
onChange: _onChange,
|
|
2065
2097
|
onBlur: _onBlur,
|
|
2066
|
-
onFocus: _onFocus
|
|
2098
|
+
onFocus: _onFocus,
|
|
2099
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
2067
2100
|
})), Array.isArray(schema.examples) && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
2068
2101
|
key: "datalist_" + id,
|
|
2069
|
-
id:
|
|
2102
|
+
id: utils.examplesId(id)
|
|
2070
2103
|
}, [].concat(new Set(schema.examples.concat(schema["default"] ? [schema["default"]] : []))).map(function (example) {
|
|
2071
2104
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
2072
2105
|
key: example,
|
|
@@ -2094,7 +2127,7 @@ function SubmitButton(_ref) {
|
|
|
2094
2127
|
}), submitText));
|
|
2095
2128
|
}
|
|
2096
2129
|
|
|
2097
|
-
var _excluded$2 = ["iconType", "icon", "className", "uiSchema"];
|
|
2130
|
+
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2098
2131
|
function IconButton(props) {
|
|
2099
2132
|
var _props$iconType = props.iconType,
|
|
2100
2133
|
iconType = _props$iconType === void 0 ? "default" : _props$iconType,
|
|
@@ -2139,7 +2172,8 @@ function RemoveButton(props) {
|
|
|
2139
2172
|
function AddButton(_ref) {
|
|
2140
2173
|
var className = _ref.className,
|
|
2141
2174
|
onClick = _ref.onClick,
|
|
2142
|
-
disabled = _ref.disabled
|
|
2175
|
+
disabled = _ref.disabled,
|
|
2176
|
+
registry = _ref.registry;
|
|
2143
2177
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2144
2178
|
className: "row"
|
|
2145
2179
|
}, /*#__PURE__*/React__default["default"].createElement("p", {
|
|
@@ -2150,7 +2184,8 @@ function AddButton(_ref) {
|
|
|
2150
2184
|
className: "btn-add col-xs-12",
|
|
2151
2185
|
title: "Add",
|
|
2152
2186
|
onClick: onClick,
|
|
2153
|
-
disabled: disabled
|
|
2187
|
+
disabled: disabled,
|
|
2188
|
+
registry: registry
|
|
2154
2189
|
})));
|
|
2155
2190
|
}
|
|
2156
2191
|
|
|
@@ -2271,7 +2306,7 @@ function FieldErrorTemplate(props) {
|
|
|
2271
2306
|
if (errors.length === 0) {
|
|
2272
2307
|
return null;
|
|
2273
2308
|
}
|
|
2274
|
-
var id = idSchema
|
|
2309
|
+
var id = utils.errorId(idSchema);
|
|
2275
2310
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
2276
2311
|
id: id,
|
|
2277
2312
|
className: "error-detail bs-callout bs-callout-info"
|
|
@@ -2295,7 +2330,7 @@ function FieldHelpTemplate(props) {
|
|
|
2295
2330
|
if (!help) {
|
|
2296
2331
|
return null;
|
|
2297
2332
|
}
|
|
2298
|
-
var id = idSchema
|
|
2333
|
+
var id = utils.helpId(idSchema);
|
|
2299
2334
|
if (typeof help === "string") {
|
|
2300
2335
|
return /*#__PURE__*/React__default["default"].createElement("p", {
|
|
2301
2336
|
id: id,
|
|
@@ -2335,14 +2370,14 @@ function ObjectFieldTemplate(props) {
|
|
|
2335
2370
|
return /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
2336
2371
|
id: idSchema.$id
|
|
2337
2372
|
}, (options.title || title) && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
2338
|
-
id: idSchema
|
|
2373
|
+
id: utils.titleId(idSchema),
|
|
2339
2374
|
title: options.title || title,
|
|
2340
2375
|
required: required,
|
|
2341
2376
|
schema: schema,
|
|
2342
2377
|
uiSchema: uiSchema,
|
|
2343
2378
|
registry: registry
|
|
2344
2379
|
}), (options.description || description) && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
2345
|
-
id: idSchema
|
|
2380
|
+
id: utils.descriptionId(idSchema),
|
|
2346
2381
|
description: options.description || description,
|
|
2347
2382
|
schema: schema,
|
|
2348
2383
|
uiSchema: uiSchema,
|
|
@@ -2353,7 +2388,8 @@ function ObjectFieldTemplate(props) {
|
|
|
2353
2388
|
className: "object-property-expand",
|
|
2354
2389
|
onClick: onAddClick(schema),
|
|
2355
2390
|
disabled: disabled || readonly,
|
|
2356
|
-
uiSchema: uiSchema
|
|
2391
|
+
uiSchema: uiSchema,
|
|
2392
|
+
registry: registry
|
|
2357
2393
|
}));
|
|
2358
2394
|
}
|
|
2359
2395
|
|
|
@@ -2395,6 +2431,7 @@ function UnsupportedField(props) {
|
|
|
2395
2431
|
function WrapIfAdditionalTemplate(props) {
|
|
2396
2432
|
var id = props.id,
|
|
2397
2433
|
classNames = props.classNames,
|
|
2434
|
+
style = props.style,
|
|
2398
2435
|
disabled = props.disabled,
|
|
2399
2436
|
label = props.label,
|
|
2400
2437
|
onKeyChange = props.onKeyChange,
|
|
@@ -2411,11 +2448,13 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2411
2448
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2412
2449
|
if (!additional) {
|
|
2413
2450
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2414
|
-
className: classNames
|
|
2451
|
+
className: classNames,
|
|
2452
|
+
style: style
|
|
2415
2453
|
}, children);
|
|
2416
2454
|
}
|
|
2417
2455
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2418
|
-
className: classNames
|
|
2456
|
+
className: classNames,
|
|
2457
|
+
style: style
|
|
2419
2458
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2420
2459
|
className: "row"
|
|
2421
2460
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -2445,7 +2484,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2445
2484
|
},
|
|
2446
2485
|
disabled: disabled || readonly,
|
|
2447
2486
|
onClick: onDropPropertyClick(label),
|
|
2448
|
-
uiSchema: uiSchema
|
|
2487
|
+
uiSchema: uiSchema,
|
|
2488
|
+
registry: registry
|
|
2449
2489
|
}))));
|
|
2450
2490
|
}
|
|
2451
2491
|
|
|
@@ -2558,7 +2598,8 @@ function DateElement(_ref) {
|
|
|
2558
2598
|
onBlur: onBlur,
|
|
2559
2599
|
onFocus: onFocus,
|
|
2560
2600
|
registry: registry,
|
|
2561
|
-
label: ""
|
|
2601
|
+
label: "",
|
|
2602
|
+
"aria-describedby": utils.ariaDescribedByIds(rootId)
|
|
2562
2603
|
});
|
|
2563
2604
|
}
|
|
2564
2605
|
/** The `AltDateWidget` is an alternative widget for rendering date properties.
|
|
@@ -2696,7 +2737,7 @@ function CheckboxWidget(_ref) {
|
|
|
2696
2737
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2697
2738
|
className: "checkbox " + (disabled || readonly ? "disabled" : "")
|
|
2698
2739
|
}, schema.description && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
2699
|
-
id: id
|
|
2740
|
+
id: utils.descriptionId(id),
|
|
2700
2741
|
description: schema.description,
|
|
2701
2742
|
schema: schema,
|
|
2702
2743
|
uiSchema: uiSchema,
|
|
@@ -2711,24 +2752,11 @@ function CheckboxWidget(_ref) {
|
|
|
2711
2752
|
autoFocus: autofocus,
|
|
2712
2753
|
onChange: handleChange,
|
|
2713
2754
|
onBlur: handleBlur,
|
|
2714
|
-
onFocus: handleFocus
|
|
2755
|
+
onFocus: handleFocus,
|
|
2756
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2715
2757
|
}), /*#__PURE__*/React__default["default"].createElement("span", null, label)));
|
|
2716
2758
|
}
|
|
2717
2759
|
|
|
2718
|
-
function selectValue(value, selected, all) {
|
|
2719
|
-
var at = all.indexOf(value);
|
|
2720
|
-
var updated = selected.slice(0, at).concat(value, selected.slice(at));
|
|
2721
|
-
// As inserting values at predefined index positions doesn't work with empty
|
|
2722
|
-
// arrays, we need to reorder the updated selection to match the initial order
|
|
2723
|
-
return updated.sort(function (a, b) {
|
|
2724
|
-
return Number(all.indexOf(a) > all.indexOf(b));
|
|
2725
|
-
});
|
|
2726
|
-
}
|
|
2727
|
-
function deselectValue(value, selected) {
|
|
2728
|
-
return selected.filter(function (v) {
|
|
2729
|
-
return v !== value;
|
|
2730
|
-
});
|
|
2731
|
-
}
|
|
2732
2760
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
2733
2761
|
* It is typically used to represent an array of enums.
|
|
2734
2762
|
*
|
|
@@ -2747,32 +2775,30 @@ function CheckboxesWidget(_ref) {
|
|
|
2747
2775
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2748
2776
|
readonly = _ref.readonly,
|
|
2749
2777
|
onChange = _ref.onChange;
|
|
2778
|
+
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2750
2779
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2751
2780
|
className: "checkboxes",
|
|
2752
2781
|
id: id
|
|
2753
2782
|
}, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2754
|
-
var checked =
|
|
2783
|
+
var checked = checkboxesValues.includes(option.value);
|
|
2755
2784
|
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) != -1;
|
|
2756
2785
|
var disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
2757
2786
|
var handleChange = function handleChange(event) {
|
|
2758
|
-
var all = enumOptions.map(function (_ref2) {
|
|
2759
|
-
var value = _ref2.value;
|
|
2760
|
-
return value;
|
|
2761
|
-
});
|
|
2762
2787
|
if (event.target.checked) {
|
|
2763
|
-
onChange(
|
|
2788
|
+
onChange(utils.enumOptionsSelectValue(option.value, checkboxesValues, enumOptions));
|
|
2764
2789
|
} else {
|
|
2765
|
-
onChange(
|
|
2790
|
+
onChange(utils.enumOptionsDeselectValue(option.value, checkboxesValues));
|
|
2766
2791
|
}
|
|
2767
2792
|
};
|
|
2768
2793
|
var checkbox = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
2769
2794
|
type: "checkbox",
|
|
2770
|
-
id: id
|
|
2795
|
+
id: utils.optionId(id, option),
|
|
2771
2796
|
name: id,
|
|
2772
2797
|
checked: checked,
|
|
2773
2798
|
disabled: disabled || itemDisabled || readonly,
|
|
2774
2799
|
autoFocus: autofocus && index === 0,
|
|
2775
|
-
onChange: handleChange
|
|
2800
|
+
onChange: handleChange,
|
|
2801
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2776
2802
|
}), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
|
|
2777
2803
|
return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
|
|
2778
2804
|
key: option.value,
|
|
@@ -2968,7 +2994,8 @@ function FileWidget(_ref2) {
|
|
|
2968
2994
|
defaultValue: "",
|
|
2969
2995
|
autoFocus: autofocus,
|
|
2970
2996
|
multiple: multiple,
|
|
2971
|
-
accept: options.accept ? String(options.accept) : undefined
|
|
2997
|
+
accept: options.accept ? String(options.accept) : undefined,
|
|
2998
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2972
2999
|
})), /*#__PURE__*/React__default["default"].createElement(FilesInfo, {
|
|
2973
3000
|
filesInfo: filesInfo
|
|
2974
3001
|
}));
|
|
@@ -3045,7 +3072,7 @@ function RadioWidget(_ref) {
|
|
|
3045
3072
|
};
|
|
3046
3073
|
var radio = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
3047
3074
|
type: "radio",
|
|
3048
|
-
id: id
|
|
3075
|
+
id: utils.optionId(id, option),
|
|
3049
3076
|
checked: checked,
|
|
3050
3077
|
name: name,
|
|
3051
3078
|
required: required,
|
|
@@ -3054,7 +3081,8 @@ function RadioWidget(_ref) {
|
|
|
3054
3081
|
autoFocus: autofocus && i === 0,
|
|
3055
3082
|
onChange: handleChange,
|
|
3056
3083
|
onBlur: handleBlur,
|
|
3057
|
-
onFocus: handleFocus
|
|
3084
|
+
onFocus: handleFocus,
|
|
3085
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3058
3086
|
}), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
|
|
3059
3087
|
return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
|
|
3060
3088
|
key: option.value,
|
|
@@ -3140,7 +3168,8 @@ function SelectWidget(_ref) {
|
|
|
3140
3168
|
autoFocus: autofocus,
|
|
3141
3169
|
onBlur: handleBlur,
|
|
3142
3170
|
onFocus: handleFocus,
|
|
3143
|
-
onChange: handleChange
|
|
3171
|
+
onChange: handleChange,
|
|
3172
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3144
3173
|
}, !multiple && schema["default"] === undefined && /*#__PURE__*/React__default["default"].createElement("option", {
|
|
3145
3174
|
value: ""
|
|
3146
3175
|
}, placeholder), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
@@ -3198,7 +3227,8 @@ function TextareaWidget(_ref) {
|
|
|
3198
3227
|
rows: options.rows,
|
|
3199
3228
|
onBlur: handleBlur,
|
|
3200
3229
|
onFocus: handleFocus,
|
|
3201
|
-
onChange: handleChange
|
|
3230
|
+
onChange: handleChange,
|
|
3231
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3202
3232
|
});
|
|
3203
3233
|
}
|
|
3204
3234
|
TextareaWidget.defaultProps = {
|
|
@@ -3583,9 +3613,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3583
3613
|
var schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
|
|
3584
3614
|
var _this$props3 = this.props,
|
|
3585
3615
|
customValidate = _this$props3.customValidate,
|
|
3586
|
-
transformErrors = _this$props3.transformErrors
|
|
3616
|
+
transformErrors = _this$props3.transformErrors,
|
|
3617
|
+
uiSchema = _this$props3.uiSchema;
|
|
3587
3618
|
var resolvedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3588
|
-
return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors);
|
|
3619
|
+
return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors, uiSchema);
|
|
3589
3620
|
}
|
|
3590
3621
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */;
|
|
3591
3622
|
_proto.renderErrors = function renderErrors(registry) {
|
|
@@ -3754,7 +3785,8 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3754
3785
|
disabled: disabled,
|
|
3755
3786
|
readonly: readonly
|
|
3756
3787
|
}), children ? children : /*#__PURE__*/React__default["default"].createElement(SubmitButton, {
|
|
3757
|
-
uiSchema: uiSchema
|
|
3788
|
+
uiSchema: uiSchema,
|
|
3789
|
+
registry: registry
|
|
3758
3790
|
}), showErrorList === "bottom" && this.renderErrors(registry));
|
|
3759
3791
|
};
|
|
3760
3792
|
return Form;
|