@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global
|
|
5
|
-
})(this, (function (exports, React, utils, get, _isEmpty, _pick, isObject, set, nanoid,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/has'), require('lodash-es/unset'), require('lodash-es/omit')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/has', 'lodash-es/unset', 'lodash-es/omit'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.React, global.utils, global.get, global._isEmpty, global._pick, global.isObject, global.set, global.nanoid, global.has, global.unset, global.omit));
|
|
5
|
+
})(this, (function (exports, React, utils, get, _isEmpty, _pick, isObject, set, nanoid, has, unset, omit) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
13
13
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
14
14
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
15
|
-
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
16
15
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
16
|
+
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
17
17
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
18
18
|
|
|
19
19
|
function _defineProperties(target, props) {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
23
23
|
descriptor.configurable = true;
|
|
24
24
|
if ("value" in descriptor) descriptor.writable = true;
|
|
25
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
25
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
@@ -102,6 +102,20 @@
|
|
|
102
102
|
}
|
|
103
103
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
104
104
|
}
|
|
105
|
+
function _toPrimitive(input, hint) {
|
|
106
|
+
if (typeof input !== "object" || input === null) return input;
|
|
107
|
+
var prim = input[Symbol.toPrimitive];
|
|
108
|
+
if (prim !== undefined) {
|
|
109
|
+
var res = prim.call(input, hint || "default");
|
|
110
|
+
if (typeof res !== "object") return res;
|
|
111
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
112
|
+
}
|
|
113
|
+
return (hint === "string" ? String : Number)(input);
|
|
114
|
+
}
|
|
115
|
+
function _toPropertyKey(arg) {
|
|
116
|
+
var key = _toPrimitive(arg, "string");
|
|
117
|
+
return typeof key === "symbol" ? key : String(key);
|
|
118
|
+
}
|
|
105
119
|
|
|
106
120
|
var _excluded$9 = ["widget"],
|
|
107
121
|
_excluded2 = ["widget"],
|
|
@@ -161,42 +175,11 @@
|
|
|
161
175
|
return schemaUtils.getDefaultFormState(itemSchema);
|
|
162
176
|
};
|
|
163
177
|
_this.onAddClick = function (event) {
|
|
164
|
-
|
|
165
|
-
event.preventDefault();
|
|
166
|
-
}
|
|
167
|
-
var onChange = _this.props.onChange;
|
|
168
|
-
var keyedFormData = _this.state.keyedFormData;
|
|
169
|
-
var newKeyedFormDataRow = {
|
|
170
|
-
key: generateRowId(),
|
|
171
|
-
item: _this._getNewFormDataRow()
|
|
172
|
-
};
|
|
173
|
-
var newKeyedFormData = [].concat(keyedFormData, [newKeyedFormDataRow]);
|
|
174
|
-
_this.setState({
|
|
175
|
-
keyedFormData: newKeyedFormData,
|
|
176
|
-
updatedKeyedFormData: true
|
|
177
|
-
}, function () {
|
|
178
|
-
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
179
|
-
});
|
|
178
|
+
_this._handleAddClick(event);
|
|
180
179
|
};
|
|
181
180
|
_this.onAddIndexClick = function (index) {
|
|
182
181
|
return function (event) {
|
|
183
|
-
|
|
184
|
-
event.preventDefault();
|
|
185
|
-
}
|
|
186
|
-
var onChange = _this.props.onChange;
|
|
187
|
-
var keyedFormData = _this.state.keyedFormData;
|
|
188
|
-
var newKeyedFormDataRow = {
|
|
189
|
-
key: generateRowId(),
|
|
190
|
-
item: _this._getNewFormDataRow()
|
|
191
|
-
};
|
|
192
|
-
var newKeyedFormData = [].concat(keyedFormData);
|
|
193
|
-
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
194
|
-
_this.setState({
|
|
195
|
-
keyedFormData: newKeyedFormData,
|
|
196
|
-
updatedKeyedFormData: true
|
|
197
|
-
}, function () {
|
|
198
|
-
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
199
|
-
});
|
|
182
|
+
_this._handleAddClick(event, index);
|
|
200
183
|
};
|
|
201
184
|
};
|
|
202
185
|
_this.onDropIndexClick = function (index) {
|
|
@@ -375,6 +358,42 @@
|
|
|
375
358
|
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
376
359
|
* that the schema is fixed and allows additional items.
|
|
377
360
|
*/;
|
|
361
|
+
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
362
|
+
* either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
|
|
363
|
+
* the state, and then returning `onChange()` with the plain form data converted from the keyed data
|
|
364
|
+
*
|
|
365
|
+
* @param event - The event for the click
|
|
366
|
+
* @param [index] - The optional index at which to add the new data
|
|
367
|
+
*/
|
|
368
|
+
_proto._handleAddClick = function _handleAddClick(event, index) {
|
|
369
|
+
if (event) {
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
}
|
|
372
|
+
var onChange = this.props.onChange;
|
|
373
|
+
var keyedFormData = this.state.keyedFormData;
|
|
374
|
+
var newKeyedFormDataRow = {
|
|
375
|
+
key: generateRowId(),
|
|
376
|
+
item: this._getNewFormDataRow()
|
|
377
|
+
};
|
|
378
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
379
|
+
if (index !== undefined) {
|
|
380
|
+
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
381
|
+
} else {
|
|
382
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
383
|
+
}
|
|
384
|
+
this.setState({
|
|
385
|
+
keyedFormData: newKeyedFormData,
|
|
386
|
+
updatedKeyedFormData: true
|
|
387
|
+
}, function () {
|
|
388
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
392
|
+
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
393
|
+
* keyed data
|
|
394
|
+
*
|
|
395
|
+
* @param event - The event for the click
|
|
396
|
+
*/;
|
|
378
397
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
379
398
|
*/
|
|
380
399
|
_proto.render = function render() {
|
|
@@ -443,8 +462,9 @@
|
|
|
443
462
|
var _schemaItems = isObject__default["default"](schema.items) ? schema.items : {};
|
|
444
463
|
var itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
|
|
445
464
|
var formData = keyedToPlainFormData(this.state.keyedFormData);
|
|
465
|
+
var canAdd = this.canAddItem(formData);
|
|
446
466
|
var arrayProps = {
|
|
447
|
-
canAdd:
|
|
467
|
+
canAdd: canAdd,
|
|
448
468
|
items: keyedFormData.map(function (keyedItem, index) {
|
|
449
469
|
var key = keyedItem.key,
|
|
450
470
|
item = keyedItem.item;
|
|
@@ -458,6 +478,7 @@
|
|
|
458
478
|
key: key,
|
|
459
479
|
index: index,
|
|
460
480
|
name: name && name + "-" + index,
|
|
481
|
+
canAdd: canAdd,
|
|
461
482
|
canMoveUp: index > 0,
|
|
462
483
|
canMoveDown: index < formData.length - 1,
|
|
463
484
|
itemSchema: itemSchema,
|
|
@@ -468,7 +489,8 @@
|
|
|
468
489
|
autofocus: autofocus && index === 0,
|
|
469
490
|
onBlur: onBlur,
|
|
470
491
|
onFocus: onFocus,
|
|
471
|
-
rawErrors: rawErrors
|
|
492
|
+
rawErrors: rawErrors,
|
|
493
|
+
totalItems: keyedFormData.length
|
|
472
494
|
});
|
|
473
495
|
}),
|
|
474
496
|
className: "field field-array field-array-of-" + itemsSchema.type,
|
|
@@ -520,7 +542,7 @@
|
|
|
520
542
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
521
543
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
522
544
|
return /*#__PURE__*/React__default["default"].createElement(Widget, {
|
|
523
|
-
id: idSchema
|
|
545
|
+
id: idSchema.$id,
|
|
524
546
|
multiple: true,
|
|
525
547
|
onChange: this.onSelectChange,
|
|
526
548
|
onBlur: onBlur,
|
|
@@ -576,7 +598,7 @@
|
|
|
576
598
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
577
599
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
578
600
|
return /*#__PURE__*/React__default["default"].createElement(Widget, {
|
|
579
|
-
id: idSchema
|
|
601
|
+
id: idSchema.$id,
|
|
580
602
|
multiple: true,
|
|
581
603
|
onChange: this.onSelectChange,
|
|
582
604
|
onBlur: onBlur,
|
|
@@ -630,7 +652,7 @@
|
|
|
630
652
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
631
653
|
return /*#__PURE__*/React__default["default"].createElement(Widget, {
|
|
632
654
|
options: options,
|
|
633
|
-
id: idSchema
|
|
655
|
+
id: idSchema.$id,
|
|
634
656
|
multiple: true,
|
|
635
657
|
onChange: this.onSelectChange,
|
|
636
658
|
onBlur: onBlur,
|
|
@@ -695,8 +717,9 @@
|
|
|
695
717
|
items = items.concat(new Array(itemSchemas.length - items.length));
|
|
696
718
|
}
|
|
697
719
|
// These are the props passed into the render function
|
|
720
|
+
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
698
721
|
var arrayProps = {
|
|
699
|
-
canAdd:
|
|
722
|
+
canAdd: canAdd,
|
|
700
723
|
className: "field field-array field-array-fixed-items",
|
|
701
724
|
disabled: disabled,
|
|
702
725
|
idSchema: idSchema,
|
|
@@ -716,6 +739,7 @@
|
|
|
716
739
|
key: key,
|
|
717
740
|
index: index,
|
|
718
741
|
name: name && name + "-" + index,
|
|
742
|
+
canAdd: canAdd,
|
|
719
743
|
canRemove: additional,
|
|
720
744
|
canMoveUp: index >= itemSchemas.length + 1,
|
|
721
745
|
canMoveDown: additional && index < items.length - 1,
|
|
@@ -727,7 +751,8 @@
|
|
|
727
751
|
autofocus: autofocus && index === 0,
|
|
728
752
|
onBlur: onBlur,
|
|
729
753
|
onFocus: onFocus,
|
|
730
|
-
rawErrors: rawErrors
|
|
754
|
+
rawErrors: rawErrors,
|
|
755
|
+
totalItems: keyedFormData.length
|
|
731
756
|
});
|
|
732
757
|
}),
|
|
733
758
|
onAddClick: this.onAddClick,
|
|
@@ -752,6 +777,7 @@
|
|
|
752
777
|
var key = props.key,
|
|
753
778
|
index = props.index,
|
|
754
779
|
name = props.name,
|
|
780
|
+
canAdd = props.canAdd,
|
|
755
781
|
_props$canRemove = props.canRemove,
|
|
756
782
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
757
783
|
_props$canMoveUp = props.canMoveUp,
|
|
@@ -766,7 +792,8 @@
|
|
|
766
792
|
autofocus = props.autofocus,
|
|
767
793
|
onBlur = props.onBlur,
|
|
768
794
|
onFocus = props.onFocus,
|
|
769
|
-
rawErrors = props.rawErrors
|
|
795
|
+
rawErrors = props.rawErrors,
|
|
796
|
+
totalItems = props.totalItems;
|
|
770
797
|
var _this$props13 = this.props,
|
|
771
798
|
disabled = _this$props13.disabled,
|
|
772
799
|
hideError = _this$props13.hideError,
|
|
@@ -819,11 +846,13 @@
|
|
|
819
846
|
}),
|
|
820
847
|
className: "array-item",
|
|
821
848
|
disabled: disabled,
|
|
849
|
+
canAdd: canAdd,
|
|
822
850
|
hasToolbar: has.toolbar,
|
|
823
851
|
hasMoveUp: has.moveUp,
|
|
824
852
|
hasMoveDown: has.moveDown,
|
|
825
853
|
hasRemove: has.remove,
|
|
826
854
|
index: index,
|
|
855
|
+
totalItems: totalItems,
|
|
827
856
|
key: key,
|
|
828
857
|
onAddIndexClick: this.onAddIndexClick,
|
|
829
858
|
onDropIndexClick: this.onDropIndexClick,
|
|
@@ -916,7 +945,7 @@
|
|
|
916
945
|
}),
|
|
917
946
|
schema: schema,
|
|
918
947
|
uiSchema: uiSchema,
|
|
919
|
-
id: idSchema
|
|
948
|
+
id: idSchema.$id,
|
|
920
949
|
onChange: onChange,
|
|
921
950
|
onFocus: onFocus,
|
|
922
951
|
onBlur: onBlur,
|
|
@@ -968,7 +997,7 @@
|
|
|
968
997
|
var _option = _step.value;
|
|
969
998
|
if (_option.properties) {
|
|
970
999
|
for (var key in _option.properties) {
|
|
971
|
-
if (key
|
|
1000
|
+
if (has__default["default"](newFormData, key)) {
|
|
972
1001
|
unset__default["default"](newFormData, key);
|
|
973
1002
|
}
|
|
974
1003
|
}
|
|
@@ -1266,7 +1295,7 @@
|
|
|
1266
1295
|
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? "-" : _getUiOptions$duplica;
|
|
1267
1296
|
var index = 0;
|
|
1268
1297
|
var newKey = preferredKey;
|
|
1269
|
-
while (newKey
|
|
1298
|
+
while (has__default["default"](formData, newKey)) {
|
|
1270
1299
|
newKey = "" + preferredKey + duplicateKeySuffixSeparator + ++index;
|
|
1271
1300
|
}
|
|
1272
1301
|
return newKey;
|
|
@@ -1577,10 +1606,10 @@
|
|
|
1577
1606
|
var _ref = errorSchema || {},
|
|
1578
1607
|
__errors = _ref.__errors,
|
|
1579
1608
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1580
|
-
// See #439: uiSchema: Don't pass consumed class names to child components
|
|
1581
|
-
var fieldUiSchema = omit__default["default"](uiSchema, ["ui:classNames", "classNames"]);
|
|
1582
|
-
if (
|
|
1583
|
-
fieldUiSchema[
|
|
1609
|
+
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1610
|
+
var fieldUiSchema = omit__default["default"](uiSchema, ["ui:classNames", "classNames", "ui:style"]);
|
|
1611
|
+
if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1612
|
+
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], ["classNames", "style"]);
|
|
1584
1613
|
}
|
|
1585
1614
|
var field = /*#__PURE__*/React__default["default"].createElement(FieldComponent, _extends({}, props, {
|
|
1586
1615
|
onChange: handleFieldComponentChange,
|
|
@@ -1637,7 +1666,7 @@
|
|
|
1637
1666
|
});
|
|
1638
1667
|
var fieldProps = {
|
|
1639
1668
|
description: /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
1640
|
-
id: id
|
|
1669
|
+
id: utils.descriptionId(id),
|
|
1641
1670
|
description: description,
|
|
1642
1671
|
schema: schema,
|
|
1643
1672
|
uiSchema: uiSchema,
|
|
@@ -1660,6 +1689,7 @@
|
|
|
1660
1689
|
hideError: hideError,
|
|
1661
1690
|
displayLabel: displayLabel,
|
|
1662
1691
|
classNames: classNames.join(" ").trim(),
|
|
1692
|
+
style: uiOptions.style,
|
|
1663
1693
|
formContext: formContext,
|
|
1664
1694
|
formData: formData,
|
|
1665
1695
|
schema: schema,
|
|
@@ -1776,7 +1806,7 @@
|
|
|
1776
1806
|
}),
|
|
1777
1807
|
schema: schema,
|
|
1778
1808
|
uiSchema: uiSchema,
|
|
1779
|
-
id: idSchema
|
|
1809
|
+
id: idSchema.$id,
|
|
1780
1810
|
label: title === undefined ? name : title,
|
|
1781
1811
|
value: formData,
|
|
1782
1812
|
onChange: onChange,
|
|
@@ -1842,9 +1872,8 @@
|
|
|
1842
1872
|
return null;
|
|
1843
1873
|
}
|
|
1844
1874
|
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, options);
|
|
1845
|
-
var id = idSchema.$id + "__description";
|
|
1846
1875
|
return /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
1847
|
-
id:
|
|
1876
|
+
id: utils.descriptionId(idSchema),
|
|
1848
1877
|
description: description,
|
|
1849
1878
|
schema: schema,
|
|
1850
1879
|
uiSchema: uiSchema,
|
|
@@ -1896,17 +1925,20 @@
|
|
|
1896
1925
|
style: btnStyle,
|
|
1897
1926
|
disabled: disabled || readonly || !hasMoveUp,
|
|
1898
1927
|
onClick: onReorderClick(index, index - 1),
|
|
1899
|
-
uiSchema: uiSchema
|
|
1928
|
+
uiSchema: uiSchema,
|
|
1929
|
+
registry: registry
|
|
1900
1930
|
}), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveDownButton, {
|
|
1901
1931
|
style: btnStyle,
|
|
1902
1932
|
disabled: disabled || readonly || !hasMoveDown,
|
|
1903
1933
|
onClick: onReorderClick(index, index + 1),
|
|
1904
|
-
uiSchema: uiSchema
|
|
1934
|
+
uiSchema: uiSchema,
|
|
1935
|
+
registry: registry
|
|
1905
1936
|
}), hasRemove && /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
1906
1937
|
style: btnStyle,
|
|
1907
1938
|
disabled: disabled || readonly,
|
|
1908
1939
|
onClick: onDropIndexClick(index),
|
|
1909
|
-
uiSchema: uiSchema
|
|
1940
|
+
uiSchema: uiSchema,
|
|
1941
|
+
registry: registry
|
|
1910
1942
|
}))));
|
|
1911
1943
|
}
|
|
1912
1944
|
|
|
@@ -1962,7 +1994,8 @@
|
|
|
1962
1994
|
className: "array-item-add",
|
|
1963
1995
|
onClick: onAddClick,
|
|
1964
1996
|
disabled: disabled || readonly,
|
|
1965
|
-
uiSchema: uiSchema
|
|
1997
|
+
uiSchema: uiSchema,
|
|
1998
|
+
registry: registry
|
|
1966
1999
|
}));
|
|
1967
2000
|
}
|
|
1968
2001
|
|
|
@@ -1985,9 +2018,8 @@
|
|
|
1985
2018
|
return null;
|
|
1986
2019
|
}
|
|
1987
2020
|
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, options);
|
|
1988
|
-
var id = idSchema.$id + "__title";
|
|
1989
2021
|
return /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
1990
|
-
id:
|
|
2022
|
+
id: utils.titleId(idSchema),
|
|
1991
2023
|
title: title,
|
|
1992
2024
|
required: required,
|
|
1993
2025
|
schema: schema,
|
|
@@ -2050,13 +2082,14 @@
|
|
|
2050
2082
|
autoFocus: autofocus,
|
|
2051
2083
|
value: inputValue
|
|
2052
2084
|
}, inputProps, {
|
|
2053
|
-
list: schema.examples ?
|
|
2085
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
2054
2086
|
onChange: _onChange,
|
|
2055
2087
|
onBlur: _onBlur,
|
|
2056
|
-
onFocus: _onFocus
|
|
2088
|
+
onFocus: _onFocus,
|
|
2089
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
2057
2090
|
})), Array.isArray(schema.examples) && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
2058
2091
|
key: "datalist_" + id,
|
|
2059
|
-
id:
|
|
2092
|
+
id: utils.examplesId(id)
|
|
2060
2093
|
}, [].concat(new Set(schema.examples.concat(schema["default"] ? [schema["default"]] : []))).map(function (example) {
|
|
2061
2094
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
2062
2095
|
key: example,
|
|
@@ -2084,7 +2117,7 @@
|
|
|
2084
2117
|
}), submitText));
|
|
2085
2118
|
}
|
|
2086
2119
|
|
|
2087
|
-
var _excluded$2 = ["iconType", "icon", "className", "uiSchema"];
|
|
2120
|
+
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2088
2121
|
function IconButton(props) {
|
|
2089
2122
|
var _props$iconType = props.iconType,
|
|
2090
2123
|
iconType = _props$iconType === void 0 ? "default" : _props$iconType,
|
|
@@ -2129,7 +2162,8 @@
|
|
|
2129
2162
|
function AddButton(_ref) {
|
|
2130
2163
|
var className = _ref.className,
|
|
2131
2164
|
onClick = _ref.onClick,
|
|
2132
|
-
disabled = _ref.disabled
|
|
2165
|
+
disabled = _ref.disabled,
|
|
2166
|
+
registry = _ref.registry;
|
|
2133
2167
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2134
2168
|
className: "row"
|
|
2135
2169
|
}, /*#__PURE__*/React__default["default"].createElement("p", {
|
|
@@ -2140,7 +2174,8 @@
|
|
|
2140
2174
|
className: "btn-add col-xs-12",
|
|
2141
2175
|
title: "Add",
|
|
2142
2176
|
onClick: onClick,
|
|
2143
|
-
disabled: disabled
|
|
2177
|
+
disabled: disabled,
|
|
2178
|
+
registry: registry
|
|
2144
2179
|
})));
|
|
2145
2180
|
}
|
|
2146
2181
|
|
|
@@ -2261,7 +2296,7 @@
|
|
|
2261
2296
|
if (errors.length === 0) {
|
|
2262
2297
|
return null;
|
|
2263
2298
|
}
|
|
2264
|
-
var id = idSchema
|
|
2299
|
+
var id = utils.errorId(idSchema);
|
|
2265
2300
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
2266
2301
|
id: id,
|
|
2267
2302
|
className: "error-detail bs-callout bs-callout-info"
|
|
@@ -2285,7 +2320,7 @@
|
|
|
2285
2320
|
if (!help) {
|
|
2286
2321
|
return null;
|
|
2287
2322
|
}
|
|
2288
|
-
var id = idSchema
|
|
2323
|
+
var id = utils.helpId(idSchema);
|
|
2289
2324
|
if (typeof help === "string") {
|
|
2290
2325
|
return /*#__PURE__*/React__default["default"].createElement("p", {
|
|
2291
2326
|
id: id,
|
|
@@ -2325,14 +2360,14 @@
|
|
|
2325
2360
|
return /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
2326
2361
|
id: idSchema.$id
|
|
2327
2362
|
}, (options.title || title) && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
2328
|
-
id: idSchema
|
|
2363
|
+
id: utils.titleId(idSchema),
|
|
2329
2364
|
title: options.title || title,
|
|
2330
2365
|
required: required,
|
|
2331
2366
|
schema: schema,
|
|
2332
2367
|
uiSchema: uiSchema,
|
|
2333
2368
|
registry: registry
|
|
2334
2369
|
}), (options.description || description) && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
2335
|
-
id: idSchema
|
|
2370
|
+
id: utils.descriptionId(idSchema),
|
|
2336
2371
|
description: options.description || description,
|
|
2337
2372
|
schema: schema,
|
|
2338
2373
|
uiSchema: uiSchema,
|
|
@@ -2343,7 +2378,8 @@
|
|
|
2343
2378
|
className: "object-property-expand",
|
|
2344
2379
|
onClick: onAddClick(schema),
|
|
2345
2380
|
disabled: disabled || readonly,
|
|
2346
|
-
uiSchema: uiSchema
|
|
2381
|
+
uiSchema: uiSchema,
|
|
2382
|
+
registry: registry
|
|
2347
2383
|
}));
|
|
2348
2384
|
}
|
|
2349
2385
|
|
|
@@ -2385,6 +2421,7 @@
|
|
|
2385
2421
|
function WrapIfAdditionalTemplate(props) {
|
|
2386
2422
|
var id = props.id,
|
|
2387
2423
|
classNames = props.classNames,
|
|
2424
|
+
style = props.style,
|
|
2388
2425
|
disabled = props.disabled,
|
|
2389
2426
|
label = props.label,
|
|
2390
2427
|
onKeyChange = props.onKeyChange,
|
|
@@ -2401,11 +2438,13 @@
|
|
|
2401
2438
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2402
2439
|
if (!additional) {
|
|
2403
2440
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2404
|
-
className: classNames
|
|
2441
|
+
className: classNames,
|
|
2442
|
+
style: style
|
|
2405
2443
|
}, children);
|
|
2406
2444
|
}
|
|
2407
2445
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2408
|
-
className: classNames
|
|
2446
|
+
className: classNames,
|
|
2447
|
+
style: style
|
|
2409
2448
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2410
2449
|
className: "row"
|
|
2411
2450
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -2435,7 +2474,8 @@
|
|
|
2435
2474
|
},
|
|
2436
2475
|
disabled: disabled || readonly,
|
|
2437
2476
|
onClick: onDropPropertyClick(label),
|
|
2438
|
-
uiSchema: uiSchema
|
|
2477
|
+
uiSchema: uiSchema,
|
|
2478
|
+
registry: registry
|
|
2439
2479
|
}))));
|
|
2440
2480
|
}
|
|
2441
2481
|
|
|
@@ -2548,7 +2588,8 @@
|
|
|
2548
2588
|
onBlur: onBlur,
|
|
2549
2589
|
onFocus: onFocus,
|
|
2550
2590
|
registry: registry,
|
|
2551
|
-
label: ""
|
|
2591
|
+
label: "",
|
|
2592
|
+
"aria-describedby": utils.ariaDescribedByIds(rootId)
|
|
2552
2593
|
});
|
|
2553
2594
|
}
|
|
2554
2595
|
/** The `AltDateWidget` is an alternative widget for rendering date properties.
|
|
@@ -2686,7 +2727,7 @@
|
|
|
2686
2727
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2687
2728
|
className: "checkbox " + (disabled || readonly ? "disabled" : "")
|
|
2688
2729
|
}, schema.description && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
2689
|
-
id: id
|
|
2730
|
+
id: utils.descriptionId(id),
|
|
2690
2731
|
description: schema.description,
|
|
2691
2732
|
schema: schema,
|
|
2692
2733
|
uiSchema: uiSchema,
|
|
@@ -2701,24 +2742,11 @@
|
|
|
2701
2742
|
autoFocus: autofocus,
|
|
2702
2743
|
onChange: handleChange,
|
|
2703
2744
|
onBlur: handleBlur,
|
|
2704
|
-
onFocus: handleFocus
|
|
2745
|
+
onFocus: handleFocus,
|
|
2746
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2705
2747
|
}), /*#__PURE__*/React__default["default"].createElement("span", null, label)));
|
|
2706
2748
|
}
|
|
2707
2749
|
|
|
2708
|
-
function selectValue(value, selected, all) {
|
|
2709
|
-
var at = all.indexOf(value);
|
|
2710
|
-
var updated = selected.slice(0, at).concat(value, selected.slice(at));
|
|
2711
|
-
// As inserting values at predefined index positions doesn't work with empty
|
|
2712
|
-
// arrays, we need to reorder the updated selection to match the initial order
|
|
2713
|
-
return updated.sort(function (a, b) {
|
|
2714
|
-
return Number(all.indexOf(a) > all.indexOf(b));
|
|
2715
|
-
});
|
|
2716
|
-
}
|
|
2717
|
-
function deselectValue(value, selected) {
|
|
2718
|
-
return selected.filter(function (v) {
|
|
2719
|
-
return v !== value;
|
|
2720
|
-
});
|
|
2721
|
-
}
|
|
2722
2750
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
2723
2751
|
* It is typically used to represent an array of enums.
|
|
2724
2752
|
*
|
|
@@ -2737,32 +2765,30 @@
|
|
|
2737
2765
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2738
2766
|
readonly = _ref.readonly,
|
|
2739
2767
|
onChange = _ref.onChange;
|
|
2768
|
+
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2740
2769
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2741
2770
|
className: "checkboxes",
|
|
2742
2771
|
id: id
|
|
2743
2772
|
}, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2744
|
-
var checked =
|
|
2773
|
+
var checked = checkboxesValues.includes(option.value);
|
|
2745
2774
|
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) != -1;
|
|
2746
2775
|
var disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
2747
2776
|
var handleChange = function handleChange(event) {
|
|
2748
|
-
var all = enumOptions.map(function (_ref2) {
|
|
2749
|
-
var value = _ref2.value;
|
|
2750
|
-
return value;
|
|
2751
|
-
});
|
|
2752
2777
|
if (event.target.checked) {
|
|
2753
|
-
onChange(
|
|
2778
|
+
onChange(utils.enumOptionsSelectValue(option.value, checkboxesValues, enumOptions));
|
|
2754
2779
|
} else {
|
|
2755
|
-
onChange(
|
|
2780
|
+
onChange(utils.enumOptionsDeselectValue(option.value, checkboxesValues));
|
|
2756
2781
|
}
|
|
2757
2782
|
};
|
|
2758
2783
|
var checkbox = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
2759
2784
|
type: "checkbox",
|
|
2760
|
-
id: id
|
|
2785
|
+
id: utils.optionId(id, option),
|
|
2761
2786
|
name: id,
|
|
2762
2787
|
checked: checked,
|
|
2763
2788
|
disabled: disabled || itemDisabled || readonly,
|
|
2764
2789
|
autoFocus: autofocus && index === 0,
|
|
2765
|
-
onChange: handleChange
|
|
2790
|
+
onChange: handleChange,
|
|
2791
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2766
2792
|
}), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
|
|
2767
2793
|
return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
|
|
2768
2794
|
key: option.value,
|
|
@@ -2958,7 +2984,8 @@
|
|
|
2958
2984
|
defaultValue: "",
|
|
2959
2985
|
autoFocus: autofocus,
|
|
2960
2986
|
multiple: multiple,
|
|
2961
|
-
accept: options.accept ? String(options.accept) : undefined
|
|
2987
|
+
accept: options.accept ? String(options.accept) : undefined,
|
|
2988
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2962
2989
|
})), /*#__PURE__*/React__default["default"].createElement(FilesInfo, {
|
|
2963
2990
|
filesInfo: filesInfo
|
|
2964
2991
|
}));
|
|
@@ -3035,7 +3062,7 @@
|
|
|
3035
3062
|
};
|
|
3036
3063
|
var radio = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
3037
3064
|
type: "radio",
|
|
3038
|
-
id: id
|
|
3065
|
+
id: utils.optionId(id, option),
|
|
3039
3066
|
checked: checked,
|
|
3040
3067
|
name: name,
|
|
3041
3068
|
required: required,
|
|
@@ -3044,7 +3071,8 @@
|
|
|
3044
3071
|
autoFocus: autofocus && i === 0,
|
|
3045
3072
|
onChange: handleChange,
|
|
3046
3073
|
onBlur: handleBlur,
|
|
3047
|
-
onFocus: handleFocus
|
|
3074
|
+
onFocus: handleFocus,
|
|
3075
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3048
3076
|
}), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
|
|
3049
3077
|
return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
|
|
3050
3078
|
key: option.value,
|
|
@@ -3130,7 +3158,8 @@
|
|
|
3130
3158
|
autoFocus: autofocus,
|
|
3131
3159
|
onBlur: handleBlur,
|
|
3132
3160
|
onFocus: handleFocus,
|
|
3133
|
-
onChange: handleChange
|
|
3161
|
+
onChange: handleChange,
|
|
3162
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3134
3163
|
}, !multiple && schema["default"] === undefined && /*#__PURE__*/React__default["default"].createElement("option", {
|
|
3135
3164
|
value: ""
|
|
3136
3165
|
}, placeholder), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
@@ -3188,7 +3217,8 @@
|
|
|
3188
3217
|
rows: options.rows,
|
|
3189
3218
|
onBlur: handleBlur,
|
|
3190
3219
|
onFocus: handleFocus,
|
|
3191
|
-
onChange: handleChange
|
|
3220
|
+
onChange: handleChange,
|
|
3221
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3192
3222
|
});
|
|
3193
3223
|
}
|
|
3194
3224
|
TextareaWidget.defaultProps = {
|
|
@@ -3573,9 +3603,10 @@
|
|
|
3573
3603
|
var schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
|
|
3574
3604
|
var _this$props3 = this.props,
|
|
3575
3605
|
customValidate = _this$props3.customValidate,
|
|
3576
|
-
transformErrors = _this$props3.transformErrors
|
|
3606
|
+
transformErrors = _this$props3.transformErrors,
|
|
3607
|
+
uiSchema = _this$props3.uiSchema;
|
|
3577
3608
|
var resolvedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3578
|
-
return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors);
|
|
3609
|
+
return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors, uiSchema);
|
|
3579
3610
|
}
|
|
3580
3611
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */;
|
|
3581
3612
|
_proto.renderErrors = function renderErrors(registry) {
|
|
@@ -3744,7 +3775,8 @@
|
|
|
3744
3775
|
disabled: disabled,
|
|
3745
3776
|
readonly: readonly
|
|
3746
3777
|
}), children ? children : /*#__PURE__*/React__default["default"].createElement(SubmitButton, {
|
|
3747
|
-
uiSchema: uiSchema
|
|
3778
|
+
uiSchema: uiSchema,
|
|
3779
|
+
registry: registry
|
|
3748
3780
|
}), showErrorList === "bottom" && this.renderErrors(registry));
|
|
3749
3781
|
};
|
|
3750
3782
|
return Form;
|