@rjsf/core 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +183 -183
- package/README.md +1 -1
- package/dist/core.cjs.development.js +1017 -826
- 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 +983 -792
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +1017 -828
- 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 +24 -17
- package/package.json +12 -12
package/dist/core.esm.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Component, useState, useCallback, useEffect, useReducer, useMemo, createRef, forwardRef } from 'react';
|
|
3
|
+
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, UI_GLOBAL_OPTIONS_KEY, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
|
|
3
4
|
import get from 'lodash-es/get';
|
|
4
5
|
import isEmpty from 'lodash-es/isEmpty';
|
|
5
6
|
import _pick from 'lodash-es/pick';
|
|
6
7
|
import _toPath from 'lodash-es/toPath';
|
|
8
|
+
import cloneDeep from 'lodash-es/cloneDeep';
|
|
7
9
|
import isObject from 'lodash-es/isObject';
|
|
8
10
|
import set from 'lodash-es/set';
|
|
9
11
|
import { nanoid } from 'nanoid';
|
|
10
12
|
import omit from 'lodash-es/omit';
|
|
13
|
+
import Markdown from 'markdown-to-jsx';
|
|
11
14
|
import has from 'lodash-es/has';
|
|
12
15
|
import unset from 'lodash-es/unset';
|
|
13
|
-
import Markdown from 'markdown-to-jsx';
|
|
14
16
|
|
|
15
17
|
function _defineProperties(target, props) {
|
|
16
18
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -147,6 +149,31 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
147
149
|
_this._handleAddClick(event, index);
|
|
148
150
|
};
|
|
149
151
|
};
|
|
152
|
+
_this.onCopyIndexClick = function (index) {
|
|
153
|
+
return function (event) {
|
|
154
|
+
if (event) {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
}
|
|
157
|
+
var onChange = _this.props.onChange;
|
|
158
|
+
var keyedFormData = _this.state.keyedFormData;
|
|
159
|
+
var newKeyedFormDataRow = {
|
|
160
|
+
key: generateRowId(),
|
|
161
|
+
item: cloneDeep(keyedFormData[index].item)
|
|
162
|
+
};
|
|
163
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
164
|
+
if (index !== undefined) {
|
|
165
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
166
|
+
} else {
|
|
167
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
168
|
+
}
|
|
169
|
+
_this.setState({
|
|
170
|
+
keyedFormData: newKeyedFormData,
|
|
171
|
+
updatedKeyedFormData: true
|
|
172
|
+
}, function () {
|
|
173
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
};
|
|
150
177
|
_this.onDropIndexClick = function (index) {
|
|
151
178
|
return function (event) {
|
|
152
179
|
if (event) {
|
|
@@ -231,7 +258,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
231
258
|
var newFormData = arrayData.map(function (item, i) {
|
|
232
259
|
// We need to treat undefined items as nulls to have validation.
|
|
233
260
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
234
|
-
var jsonValue = typeof value ===
|
|
261
|
+
var jsonValue = typeof value === 'undefined' ? null : value;
|
|
235
262
|
return index === i ? jsonValue : item;
|
|
236
263
|
});
|
|
237
264
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends2 = {}, _extends2[index] = newErrorSchema, _extends2)), id);
|
|
@@ -291,10 +318,10 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
291
318
|
if (Array.isArray(itemSchema.type)) {
|
|
292
319
|
// While we don't yet support composite/nullable jsonschema types, it's
|
|
293
320
|
// future-proof to check for requirement against these.
|
|
294
|
-
return !itemSchema.type.includes(
|
|
321
|
+
return !itemSchema.type.includes('null');
|
|
295
322
|
}
|
|
296
323
|
// All non-null array item types are inherently required by design
|
|
297
|
-
return itemSchema.type !==
|
|
324
|
+
return itemSchema.type !== 'null';
|
|
298
325
|
}
|
|
299
326
|
/** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
|
|
300
327
|
* then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
|
|
@@ -306,8 +333,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
306
333
|
_proto.canAddItem = function canAddItem(formItems) {
|
|
307
334
|
var _this$props6 = this.props,
|
|
308
335
|
schema = _this$props6.schema,
|
|
309
|
-
uiSchema = _this$props6.uiSchema
|
|
310
|
-
|
|
336
|
+
uiSchema = _this$props6.uiSchema,
|
|
337
|
+
registry = _this$props6.registry;
|
|
338
|
+
var _getUiOptions = getUiOptions(uiSchema, registry.globalUiOptions),
|
|
311
339
|
addable = _getUiOptions.addable;
|
|
312
340
|
if (addable !== false) {
|
|
313
341
|
// if ui:options.addable was not explicitly set to false, we can add
|
|
@@ -371,8 +399,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
371
399
|
translateString = registry.translateString;
|
|
372
400
|
if (!(ITEMS_KEY in schema)) {
|
|
373
401
|
var uiOptions = getUiOptions(uiSchema);
|
|
374
|
-
var UnsupportedFieldTemplate = getTemplate(
|
|
375
|
-
return
|
|
402
|
+
var UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
403
|
+
return jsx(UnsupportedFieldTemplate, {
|
|
376
404
|
schema: schema,
|
|
377
405
|
idSchema: idSchema,
|
|
378
406
|
reason: translateString(TranslatableString.MissingItems),
|
|
@@ -418,7 +446,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
418
446
|
onFocus = _this$props8.onFocus,
|
|
419
447
|
idPrefix = _this$props8.idPrefix,
|
|
420
448
|
_this$props8$idSepara = _this$props8.idSeparator,
|
|
421
|
-
idSeparator = _this$props8$idSepara === void 0 ?
|
|
449
|
+
idSeparator = _this$props8$idSepara === void 0 ? '_' : _this$props8$idSepara,
|
|
422
450
|
rawErrors = _this$props8.rawErrors;
|
|
423
451
|
var keyedFormData = this.state.keyedFormData;
|
|
424
452
|
var title = schema.title === undefined ? name : schema.title;
|
|
@@ -473,8 +501,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
473
501
|
rawErrors: rawErrors,
|
|
474
502
|
registry: registry
|
|
475
503
|
};
|
|
476
|
-
var Template = getTemplate(
|
|
477
|
-
return
|
|
504
|
+
var Template = getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
505
|
+
return jsx(Template, _extends({}, arrayProps));
|
|
478
506
|
}
|
|
479
507
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
480
508
|
*/;
|
|
@@ -507,8 +535,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
507
535
|
widget = _getUiOptions2.widget,
|
|
508
536
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
509
537
|
var Widget = getWidget(schema, widget, widgets);
|
|
510
|
-
return
|
|
538
|
+
return jsx(Widget, {
|
|
511
539
|
id: idSchema.$id,
|
|
540
|
+
name: name,
|
|
512
541
|
multiple: true,
|
|
513
542
|
onChange: this.onSelectChange,
|
|
514
543
|
onBlur: onBlur,
|
|
@@ -560,11 +589,12 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
560
589
|
var enumOptions = optionsList(itemsSchema);
|
|
561
590
|
var _getUiOptions3 = getUiOptions(uiSchema),
|
|
562
591
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
563
|
-
widget = _getUiOptions3$widget === void 0 ?
|
|
592
|
+
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
564
593
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
565
594
|
var Widget = getWidget(schema, widget, widgets);
|
|
566
|
-
return
|
|
595
|
+
return jsx(Widget, {
|
|
567
596
|
id: idSchema.$id,
|
|
597
|
+
name: name,
|
|
568
598
|
multiple: true,
|
|
569
599
|
onChange: this.onSelectChange,
|
|
570
600
|
onBlur: onBlur,
|
|
@@ -613,12 +643,13 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
613
643
|
formContext = registry.formContext;
|
|
614
644
|
var _getUiOptions4 = getUiOptions(uiSchema),
|
|
615
645
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
616
|
-
widget = _getUiOptions4$widget === void 0 ?
|
|
646
|
+
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
617
647
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
618
648
|
var Widget = getWidget(schema, widget, widgets);
|
|
619
|
-
return
|
|
649
|
+
return jsx(Widget, {
|
|
620
650
|
options: options,
|
|
621
651
|
id: idSchema.$id,
|
|
652
|
+
name: name,
|
|
622
653
|
multiple: true,
|
|
623
654
|
onChange: this.onSelectChange,
|
|
624
655
|
onBlur: onBlur,
|
|
@@ -634,7 +665,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
634
665
|
formContext: formContext,
|
|
635
666
|
autofocus: autofocus,
|
|
636
667
|
rawErrors: rawErrors,
|
|
637
|
-
label:
|
|
668
|
+
label: ''
|
|
638
669
|
});
|
|
639
670
|
}
|
|
640
671
|
/** Renders an array that has a maximum limit of items
|
|
@@ -650,7 +681,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
650
681
|
errorSchema = _this$props12.errorSchema,
|
|
651
682
|
idPrefix = _this$props12.idPrefix,
|
|
652
683
|
_this$props12$idSepar = _this$props12.idSeparator,
|
|
653
|
-
idSeparator = _this$props12$idSepar === void 0 ?
|
|
684
|
+
idSeparator = _this$props12$idSepar === void 0 ? '_' : _this$props12$idSepar,
|
|
654
685
|
idSchema = _this$props12.idSchema,
|
|
655
686
|
name = _this$props12.name,
|
|
656
687
|
_this$props12$disable = _this$props12.disabled,
|
|
@@ -686,7 +717,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
686
717
|
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
687
718
|
var arrayProps = {
|
|
688
719
|
canAdd: canAdd,
|
|
689
|
-
className:
|
|
720
|
+
className: 'field field-array field-array-fixed-items',
|
|
690
721
|
disabled: disabled,
|
|
691
722
|
idSchema: idSchema,
|
|
692
723
|
formData: formData,
|
|
@@ -731,8 +762,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
731
762
|
formContext: formContext,
|
|
732
763
|
rawErrors: rawErrors
|
|
733
764
|
};
|
|
734
|
-
var Template = getTemplate(
|
|
735
|
-
return
|
|
765
|
+
var Template = getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
766
|
+
return jsx(Template, _extends({}, arrayProps));
|
|
736
767
|
}
|
|
737
768
|
/** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
|
|
738
769
|
* back to the `ArrayFieldItemTemplate`.
|
|
@@ -746,10 +777,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
746
777
|
canAdd = props.canAdd,
|
|
747
778
|
_props$canRemove = props.canRemove,
|
|
748
779
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
_props$canMoveDown = props.canMoveDown,
|
|
752
|
-
canMoveDown = _props$canMoveDown === void 0 ? true : _props$canMoveDown,
|
|
780
|
+
canMoveUp = props.canMoveUp,
|
|
781
|
+
canMoveDown = props.canMoveDown,
|
|
753
782
|
itemSchema = props.itemSchema,
|
|
754
783
|
itemData = props.itemData,
|
|
755
784
|
itemUiSchema = props.itemUiSchema,
|
|
@@ -771,16 +800,20 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
771
800
|
formContext = _this$props13.formContext;
|
|
772
801
|
var _registry$fields = registry.fields,
|
|
773
802
|
ArraySchemaField = _registry$fields.ArraySchemaField,
|
|
774
|
-
SchemaField = _registry$fields.SchemaField
|
|
803
|
+
SchemaField = _registry$fields.SchemaField,
|
|
804
|
+
globalUiOptions = registry.globalUiOptions;
|
|
775
805
|
var ItemSchemaField = ArraySchemaField || SchemaField;
|
|
776
|
-
var _getUiOptions5 = getUiOptions(uiSchema),
|
|
806
|
+
var _getUiOptions5 = getUiOptions(uiSchema, globalUiOptions),
|
|
777
807
|
_getUiOptions5$ordera = _getUiOptions5.orderable,
|
|
778
808
|
orderable = _getUiOptions5$ordera === void 0 ? true : _getUiOptions5$ordera,
|
|
779
809
|
_getUiOptions5$remova = _getUiOptions5.removable,
|
|
780
|
-
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova
|
|
810
|
+
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova,
|
|
811
|
+
_getUiOptions5$copyab = _getUiOptions5.copyable,
|
|
812
|
+
copyable = _getUiOptions5$copyab === void 0 ? false : _getUiOptions5$copyab;
|
|
781
813
|
var has = {
|
|
782
814
|
moveUp: orderable && canMoveUp,
|
|
783
815
|
moveDown: orderable && canMoveDown,
|
|
816
|
+
copy: copyable && canAdd,
|
|
784
817
|
remove: removable && canRemove,
|
|
785
818
|
toolbar: false
|
|
786
819
|
};
|
|
@@ -788,7 +821,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
788
821
|
return has[key];
|
|
789
822
|
});
|
|
790
823
|
return {
|
|
791
|
-
children:
|
|
824
|
+
children: jsx(ItemSchemaField, {
|
|
792
825
|
name: name,
|
|
793
826
|
index: index,
|
|
794
827
|
schema: itemSchema,
|
|
@@ -810,9 +843,10 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
810
843
|
autofocus: autofocus,
|
|
811
844
|
rawErrors: rawErrors
|
|
812
845
|
}),
|
|
813
|
-
className:
|
|
846
|
+
className: 'array-item',
|
|
814
847
|
disabled: disabled,
|
|
815
848
|
canAdd: canAdd,
|
|
849
|
+
hasCopy: has.copy,
|
|
816
850
|
hasToolbar: has.toolbar,
|
|
817
851
|
hasMoveUp: has.moveUp,
|
|
818
852
|
hasMoveDown: has.moveDown,
|
|
@@ -821,6 +855,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
821
855
|
totalItems: totalItems,
|
|
822
856
|
key: key,
|
|
823
857
|
onAddIndexClick: this.onAddIndexClick,
|
|
858
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
824
859
|
onDropIndexClick: this.onDropIndexClick,
|
|
825
860
|
onReorderClick: this.onReorderClick,
|
|
826
861
|
readonly: readonly,
|
|
@@ -836,7 +871,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
836
871
|
schema = _this$props14.schema,
|
|
837
872
|
registry = _this$props14.registry;
|
|
838
873
|
var translateString = registry.translateString;
|
|
839
|
-
return get(schema, [ITEMS_KEY,
|
|
874
|
+
return get(schema, [ITEMS_KEY, 'title'], get(schema, [ITEMS_KEY, 'description'], translateString(TranslatableString.ArrayItemTitle)));
|
|
840
875
|
}
|
|
841
876
|
}]);
|
|
842
877
|
return ArrayField;
|
|
@@ -869,7 +904,7 @@ function BooleanField(props) {
|
|
|
869
904
|
translateString = registry.translateString;
|
|
870
905
|
var _getUiOptions = getUiOptions(uiSchema),
|
|
871
906
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
872
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
907
|
+
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
873
908
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
874
909
|
var Widget = getWidget(schema, widget, widgets);
|
|
875
910
|
var yes = translateString(TranslatableString.YesLabel);
|
|
@@ -894,7 +929,7 @@ function BooleanField(props) {
|
|
|
894
929
|
var schemaWithEnumNames = schema;
|
|
895
930
|
var enums = (_schema$enum = schema["enum"]) != null ? _schema$enum : [true, false];
|
|
896
931
|
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every(function (v) {
|
|
897
|
-
return typeof v ===
|
|
932
|
+
return typeof v === 'boolean';
|
|
898
933
|
})) {
|
|
899
934
|
enumOptions = [{
|
|
900
935
|
value: enums[0],
|
|
@@ -911,13 +946,14 @@ function BooleanField(props) {
|
|
|
911
946
|
});
|
|
912
947
|
}
|
|
913
948
|
}
|
|
914
|
-
return
|
|
949
|
+
return jsx(Widget, {
|
|
915
950
|
options: _extends({}, options, {
|
|
916
951
|
enumOptions: enumOptions
|
|
917
952
|
}),
|
|
918
953
|
schema: schema,
|
|
919
954
|
uiSchema: uiSchema,
|
|
920
955
|
id: idSchema.$id,
|
|
956
|
+
name: name,
|
|
921
957
|
onChange: onChange,
|
|
922
958
|
onFocus: onFocus,
|
|
923
959
|
onBlur: onBlur,
|
|
@@ -967,7 +1003,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
967
1003
|
if (newFormData && newOption) {
|
|
968
1004
|
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
969
1005
|
// so that only the root objects themselves are created without adding undefined children properties
|
|
970
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData,
|
|
1006
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
971
1007
|
}
|
|
972
1008
|
onChange(newFormData, undefined, _this.getFieldId());
|
|
973
1009
|
_this.setState({
|
|
@@ -1054,12 +1090,13 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1054
1090
|
var _this$props4 = this.props,
|
|
1055
1091
|
idSchema = _this$props4.idSchema,
|
|
1056
1092
|
schema = _this$props4.schema;
|
|
1057
|
-
return "" + idSchema.$id + (schema.oneOf ?
|
|
1093
|
+
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1058
1094
|
}
|
|
1059
1095
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1060
1096
|
*/;
|
|
1061
1097
|
_proto.render = function render() {
|
|
1062
1098
|
var _this$props5 = this.props,
|
|
1099
|
+
name = _this$props5.name,
|
|
1063
1100
|
baseType = _this$props5.baseType,
|
|
1064
1101
|
_this$props5$disabled = _this$props5.disabled,
|
|
1065
1102
|
disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
|
|
@@ -1080,7 +1117,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1080
1117
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1081
1118
|
var _getUiOptions = getUiOptions(uiSchema),
|
|
1082
1119
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1083
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
1120
|
+
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1084
1121
|
placeholder = _getUiOptions.placeholder,
|
|
1085
1122
|
autofocus = _getUiOptions.autofocus,
|
|
1086
1123
|
autocomplete = _getUiOptions.autocomplete,
|
|
@@ -1088,7 +1125,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1088
1125
|
title = _getUiOptions$title === void 0 ? schema.title : _getUiOptions$title,
|
|
1089
1126
|
uiOptions = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$7);
|
|
1090
1127
|
var Widget = getWidget({
|
|
1091
|
-
type:
|
|
1128
|
+
type: 'number'
|
|
1092
1129
|
}, widget, widgets);
|
|
1093
1130
|
var rawErrors = get(errorSchema, ERRORS_KEY, []);
|
|
1094
1131
|
var fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
|
|
@@ -1109,36 +1146,39 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1109
1146
|
value: index
|
|
1110
1147
|
};
|
|
1111
1148
|
});
|
|
1112
|
-
return
|
|
1113
|
-
className:
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1149
|
+
return jsxs("div", {
|
|
1150
|
+
className: 'panel panel-default panel-body',
|
|
1151
|
+
children: [jsx("div", {
|
|
1152
|
+
className: 'form-group',
|
|
1153
|
+
children: jsx(Widget, {
|
|
1154
|
+
id: this.getFieldId(),
|
|
1155
|
+
name: "" + name + (schema.oneOf ? '__oneof_select' : '__anyof_select'),
|
|
1156
|
+
schema: {
|
|
1157
|
+
type: 'number',
|
|
1158
|
+
"default": 0
|
|
1159
|
+
},
|
|
1160
|
+
onChange: this.onOptionChange,
|
|
1161
|
+
onBlur: onBlur,
|
|
1162
|
+
onFocus: onFocus,
|
|
1163
|
+
disabled: disabled || isEmpty(enumOptions),
|
|
1164
|
+
multiple: false,
|
|
1165
|
+
rawErrors: rawErrors,
|
|
1166
|
+
errorSchema: fieldErrorSchema,
|
|
1167
|
+
value: selectedOption >= 0 ? selectedOption : undefined,
|
|
1168
|
+
options: _extends({
|
|
1169
|
+
enumOptions: enumOptions
|
|
1170
|
+
}, uiOptions),
|
|
1171
|
+
registry: registry,
|
|
1172
|
+
formContext: formContext,
|
|
1173
|
+
placeholder: placeholder,
|
|
1174
|
+
autocomplete: autocomplete,
|
|
1175
|
+
autofocus: autofocus,
|
|
1176
|
+
label: ''
|
|
1177
|
+
})
|
|
1178
|
+
}), option !== null && jsx(_SchemaField, _extends({}, this.props, {
|
|
1179
|
+
schema: optionSchema
|
|
1180
|
+
}))]
|
|
1181
|
+
});
|
|
1142
1182
|
};
|
|
1143
1183
|
return AnyOfField;
|
|
1144
1184
|
}(Component);
|
|
@@ -1189,27 +1229,27 @@ function NumberField(props) {
|
|
|
1189
1229
|
setLastValue(value);
|
|
1190
1230
|
// Normalize decimals that don't start with a zero character in advance so
|
|
1191
1231
|
// that the rest of the normalization logic is simpler
|
|
1192
|
-
if (("" + value).charAt(0) ===
|
|
1232
|
+
if (("" + value).charAt(0) === '.') {
|
|
1193
1233
|
value = "0" + value;
|
|
1194
1234
|
}
|
|
1195
1235
|
// Check that the value is a string (this can happen if the widget used is a
|
|
1196
1236
|
// <select>, due to an enum declaration etc) then, if the value ends in a
|
|
1197
1237
|
// trailing decimal point or multiple zeroes, strip the trailing values
|
|
1198
|
-
var processed = typeof value ===
|
|
1238
|
+
var processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix) ? asNumber(value.replace(trailingCharMatcher, '')) : asNumber(value);
|
|
1199
1239
|
onChange(processed);
|
|
1200
1240
|
}, [onChange]);
|
|
1201
|
-
if (typeof lastValue ===
|
|
1241
|
+
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
1202
1242
|
// Construct a regular expression that checks for a string that consists
|
|
1203
1243
|
// of the formData value suffixed with zero or one '.' characters and zero
|
|
1204
1244
|
// or more '0' characters
|
|
1205
|
-
var re = new RegExp(("" + value).replace(
|
|
1245
|
+
var re = new RegExp(("" + value).replace('.', '\\.') + '\\.?0*$');
|
|
1206
1246
|
// If the cached "lastValue" is a match, use that instead of the formData
|
|
1207
1247
|
// value to prevent the input value from changing in the UI
|
|
1208
1248
|
if (lastValue.match(re)) {
|
|
1209
1249
|
value = lastValue;
|
|
1210
1250
|
}
|
|
1211
1251
|
}
|
|
1212
|
-
return
|
|
1252
|
+
return jsx(StringField, _extends({}, props, {
|
|
1213
1253
|
formData: value,
|
|
1214
1254
|
onChange: handleChange
|
|
1215
1255
|
}));
|
|
@@ -1250,7 +1290,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1250
1290
|
// fields which are "mandated" by the schema, these fields can
|
|
1251
1291
|
// be set to undefined by clicking a "delete field" button, so
|
|
1252
1292
|
// set empty values to the empty string.
|
|
1253
|
-
value =
|
|
1293
|
+
value = '';
|
|
1254
1294
|
}
|
|
1255
1295
|
var newFormData = _extends({}, formData, (_extends2 = {}, _extends2[name] = value, _extends2));
|
|
1256
1296
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends3 = {}, _extends3[name] = newErrorSchema, _extends3)), id);
|
|
@@ -1268,10 +1308,12 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1268
1308
|
};
|
|
1269
1309
|
};
|
|
1270
1310
|
_this.getAvailableKey = function (preferredKey, formData) {
|
|
1271
|
-
var
|
|
1272
|
-
|
|
1311
|
+
var _this$props3 = _this.props,
|
|
1312
|
+
uiSchema = _this$props3.uiSchema,
|
|
1313
|
+
registry = _this$props3.registry;
|
|
1314
|
+
var _getUiOptions = getUiOptions(uiSchema, registry.globalUiOptions),
|
|
1273
1315
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1274
|
-
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ?
|
|
1316
|
+
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1275
1317
|
var index = 0;
|
|
1276
1318
|
var newKey = preferredKey;
|
|
1277
1319
|
while (has(formData, newKey)) {
|
|
@@ -1285,10 +1327,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1285
1327
|
if (oldValue === value) {
|
|
1286
1328
|
return;
|
|
1287
1329
|
}
|
|
1288
|
-
var _this$
|
|
1289
|
-
formData = _this$
|
|
1290
|
-
onChange = _this$
|
|
1291
|
-
errorSchema = _this$
|
|
1330
|
+
var _this$props4 = _this.props,
|
|
1331
|
+
formData = _this$props4.formData,
|
|
1332
|
+
onChange = _this$props4.onChange,
|
|
1333
|
+
errorSchema = _this$props4.errorSchema;
|
|
1292
1334
|
value = _this.getAvailableKey(value, formData);
|
|
1293
1335
|
var newFormData = _extends({}, formData);
|
|
1294
1336
|
var newKeys = (_newKeys = {}, _newKeys[oldValue] = value, _newKeys);
|
|
@@ -1309,10 +1351,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1309
1351
|
if (!schema.additionalProperties) {
|
|
1310
1352
|
return;
|
|
1311
1353
|
}
|
|
1312
|
-
var _this$
|
|
1313
|
-
formData = _this$
|
|
1314
|
-
onChange = _this$
|
|
1315
|
-
registry = _this$
|
|
1354
|
+
var _this$props5 = _this.props,
|
|
1355
|
+
formData = _this$props5.formData,
|
|
1356
|
+
onChange = _this$props5.onChange,
|
|
1357
|
+
registry = _this$props5.registry;
|
|
1316
1358
|
var newFormData = _extends({}, formData);
|
|
1317
1359
|
var type = undefined;
|
|
1318
1360
|
if (isObject(schema.additionalProperties)) {
|
|
@@ -1326,10 +1368,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1326
1368
|
type = apSchema.type;
|
|
1327
1369
|
}
|
|
1328
1370
|
if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
|
|
1329
|
-
type =
|
|
1371
|
+
type = 'object';
|
|
1330
1372
|
}
|
|
1331
1373
|
}
|
|
1332
|
-
var newKey = _this.getAvailableKey(
|
|
1374
|
+
var newKey = _this.getAvailableKey('newKey', newFormData);
|
|
1333
1375
|
// Cast this to make the `set` work properly
|
|
1334
1376
|
set(newFormData, newKey, _this.getDefaultValue(type));
|
|
1335
1377
|
onChange(newFormData);
|
|
@@ -1362,17 +1404,17 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1362
1404
|
_proto.getDefaultValue = function getDefaultValue(type) {
|
|
1363
1405
|
var translateString = this.props.registry.translateString;
|
|
1364
1406
|
switch (type) {
|
|
1365
|
-
case
|
|
1407
|
+
case 'array':
|
|
1366
1408
|
return [];
|
|
1367
|
-
case
|
|
1409
|
+
case 'boolean':
|
|
1368
1410
|
return false;
|
|
1369
|
-
case
|
|
1411
|
+
case 'null':
|
|
1370
1412
|
return null;
|
|
1371
|
-
case
|
|
1413
|
+
case 'number':
|
|
1372
1414
|
return 0;
|
|
1373
|
-
case
|
|
1415
|
+
case 'object':
|
|
1374
1416
|
return {};
|
|
1375
|
-
case
|
|
1417
|
+
case 'string':
|
|
1376
1418
|
default:
|
|
1377
1419
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1378
1420
|
return translateString(TranslatableString.NewStringDefault);
|
|
@@ -1387,60 +1429,67 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1387
1429
|
*/
|
|
1388
1430
|
_proto.render = function render() {
|
|
1389
1431
|
var _this2 = this;
|
|
1390
|
-
var _this$
|
|
1391
|
-
rawSchema = _this$
|
|
1392
|
-
_this$
|
|
1393
|
-
uiSchema = _this$
|
|
1394
|
-
formData = _this$
|
|
1395
|
-
errorSchema = _this$
|
|
1396
|
-
idSchema = _this$
|
|
1397
|
-
name = _this$
|
|
1398
|
-
_this$
|
|
1399
|
-
required = _this$
|
|
1400
|
-
_this$
|
|
1401
|
-
disabled = _this$
|
|
1402
|
-
_this$
|
|
1403
|
-
readonly = _this$
|
|
1404
|
-
hideError = _this$
|
|
1405
|
-
idPrefix = _this$
|
|
1406
|
-
idSeparator = _this$
|
|
1407
|
-
onBlur = _this$
|
|
1408
|
-
onFocus = _this$
|
|
1409
|
-
registry = _this$
|
|
1432
|
+
var _this$props6 = this.props,
|
|
1433
|
+
rawSchema = _this$props6.schema,
|
|
1434
|
+
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
1435
|
+
uiSchema = _this$props6$uiSchema === void 0 ? {} : _this$props6$uiSchema,
|
|
1436
|
+
formData = _this$props6.formData,
|
|
1437
|
+
errorSchema = _this$props6.errorSchema,
|
|
1438
|
+
idSchema = _this$props6.idSchema,
|
|
1439
|
+
name = _this$props6.name,
|
|
1440
|
+
_this$props6$required = _this$props6.required,
|
|
1441
|
+
required = _this$props6$required === void 0 ? false : _this$props6$required,
|
|
1442
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1443
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1444
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
1445
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
1446
|
+
hideError = _this$props6.hideError,
|
|
1447
|
+
idPrefix = _this$props6.idPrefix,
|
|
1448
|
+
idSeparator = _this$props6.idSeparator,
|
|
1449
|
+
onBlur = _this$props6.onBlur,
|
|
1450
|
+
onFocus = _this$props6.onFocus,
|
|
1451
|
+
registry = _this$props6.registry;
|
|
1410
1452
|
var fields = registry.fields,
|
|
1411
1453
|
formContext = registry.formContext,
|
|
1412
|
-
schemaUtils = registry.schemaUtils
|
|
1454
|
+
schemaUtils = registry.schemaUtils,
|
|
1455
|
+
translateString = registry.translateString;
|
|
1413
1456
|
var SchemaField = fields.SchemaField;
|
|
1414
1457
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1415
1458
|
var uiOptions = getUiOptions(uiSchema);
|
|
1416
1459
|
var _schema$properties = schema.properties,
|
|
1417
1460
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1418
|
-
var title = schema.title === undefined ? name : schema.title;
|
|
1461
|
+
var title = uiOptions.title || (schema.title === undefined ? name : schema.title);
|
|
1419
1462
|
var description = uiOptions.description || schema.description;
|
|
1420
1463
|
var orderedProperties;
|
|
1421
1464
|
try {
|
|
1422
1465
|
var properties = Object.keys(schemaProperties);
|
|
1423
1466
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
1424
1467
|
} catch (err) {
|
|
1425
|
-
return
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1468
|
+
return jsxs("div", {
|
|
1469
|
+
children: [jsx("p", {
|
|
1470
|
+
className: 'config-error',
|
|
1471
|
+
style: {
|
|
1472
|
+
color: 'red'
|
|
1473
|
+
},
|
|
1474
|
+
children: jsx(Markdown, {
|
|
1475
|
+
children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message])
|
|
1476
|
+
})
|
|
1477
|
+
}), jsx("pre", {
|
|
1478
|
+
children: JSON.stringify(schema)
|
|
1479
|
+
})]
|
|
1480
|
+
});
|
|
1431
1481
|
}
|
|
1432
|
-
var Template = getTemplate(
|
|
1482
|
+
var Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1433
1483
|
var templateProps = {
|
|
1434
|
-
title:
|
|
1484
|
+
title: title,
|
|
1435
1485
|
description: description,
|
|
1436
1486
|
properties: orderedProperties.map(function (name) {
|
|
1437
1487
|
var addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
|
|
1438
1488
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
1439
|
-
var hidden = getUiOptions(fieldUiSchema).widget ===
|
|
1489
|
+
var hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
1440
1490
|
var fieldIdSchema = get(idSchema, [name], {});
|
|
1441
1491
|
return {
|
|
1442
|
-
content:
|
|
1443
|
-
key: name,
|
|
1492
|
+
content: jsx(SchemaField, {
|
|
1444
1493
|
name: name,
|
|
1445
1494
|
required: _this2.isRequired(name),
|
|
1446
1495
|
schema: get(schema, [PROPERTIES_KEY, name], {}),
|
|
@@ -1461,7 +1510,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1461
1510
|
readonly: readonly,
|
|
1462
1511
|
hideError: hideError,
|
|
1463
1512
|
onDropPropertyClick: _this2.onDropPropertyClick
|
|
1464
|
-
}),
|
|
1513
|
+
}, name),
|
|
1465
1514
|
name: name,
|
|
1466
1515
|
readonly: readonly,
|
|
1467
1516
|
disabled: disabled,
|
|
@@ -1479,7 +1528,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1479
1528
|
formContext: formContext,
|
|
1480
1529
|
registry: registry
|
|
1481
1530
|
};
|
|
1482
|
-
return
|
|
1531
|
+
return jsx(Template, _extends({}, templateProps, {
|
|
1483
1532
|
onAddClick: this.handleAddClick
|
|
1484
1533
|
}));
|
|
1485
1534
|
};
|
|
@@ -1489,13 +1538,13 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1489
1538
|
var _excluded$6 = ["__errors"];
|
|
1490
1539
|
/** The map of component type to FieldName */
|
|
1491
1540
|
var COMPONENT_TYPES = {
|
|
1492
|
-
array:
|
|
1493
|
-
"boolean":
|
|
1494
|
-
integer:
|
|
1495
|
-
number:
|
|
1496
|
-
object:
|
|
1497
|
-
string:
|
|
1498
|
-
"null":
|
|
1541
|
+
array: 'ArrayField',
|
|
1542
|
+
"boolean": 'BooleanField',
|
|
1543
|
+
integer: 'NumberField',
|
|
1544
|
+
number: 'NumberField',
|
|
1545
|
+
object: 'ObjectField',
|
|
1546
|
+
string: 'StringField',
|
|
1547
|
+
"null": 'NullField'
|
|
1499
1548
|
};
|
|
1500
1549
|
/** Computes and returns which `Field` implementation to return in order to render the field represented by the
|
|
1501
1550
|
* `schema`. The `uiOptions` are used to alter what potential `Field` implementation is actually returned. If no
|
|
@@ -1511,14 +1560,14 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1511
1560
|
var field = uiOptions.field;
|
|
1512
1561
|
var fields = registry.fields,
|
|
1513
1562
|
translateString = registry.translateString;
|
|
1514
|
-
if (typeof field ===
|
|
1563
|
+
if (typeof field === 'function') {
|
|
1515
1564
|
return field;
|
|
1516
1565
|
}
|
|
1517
|
-
if (typeof field ===
|
|
1566
|
+
if (typeof field === 'string' && field in fields) {
|
|
1518
1567
|
return fields[field];
|
|
1519
1568
|
}
|
|
1520
1569
|
var schemaType = getSchemaType(schema);
|
|
1521
|
-
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType ||
|
|
1570
|
+
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
|
|
1522
1571
|
var componentName = COMPONENT_TYPES[type];
|
|
1523
1572
|
// If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
|
|
1524
1573
|
// render a field and let the MultiSchemaField component handle the form display
|
|
@@ -1528,8 +1577,8 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1528
1577
|
};
|
|
1529
1578
|
}
|
|
1530
1579
|
return componentName in fields ? fields[componentName] : function () {
|
|
1531
|
-
var UnsupportedFieldTemplate = getTemplate(
|
|
1532
|
-
return
|
|
1580
|
+
var UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
1581
|
+
return jsx(UnsupportedFieldTemplate, {
|
|
1533
1582
|
schema: schema,
|
|
1534
1583
|
idSchema: idSchema,
|
|
1535
1584
|
reason: translateString(TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
@@ -1560,19 +1609,20 @@ function SchemaFieldRender(props) {
|
|
|
1560
1609
|
_props$wasPropertyKey = props.wasPropertyKeyModified,
|
|
1561
1610
|
wasPropertyKeyModified = _props$wasPropertyKey === void 0 ? false : _props$wasPropertyKey;
|
|
1562
1611
|
var formContext = registry.formContext,
|
|
1563
|
-
schemaUtils = registry.schemaUtils
|
|
1564
|
-
|
|
1565
|
-
var
|
|
1566
|
-
var
|
|
1567
|
-
var
|
|
1568
|
-
var
|
|
1612
|
+
schemaUtils = registry.schemaUtils,
|
|
1613
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1614
|
+
var uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
1615
|
+
var FieldTemplate = getTemplate('FieldTemplate', registry, uiOptions);
|
|
1616
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1617
|
+
var FieldHelpTemplate = getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
1618
|
+
var FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
1569
1619
|
var schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1570
1620
|
var fieldId = _idSchema[ID_KEY];
|
|
1571
1621
|
var idSchema = mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
1572
1622
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
1573
1623
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
1574
1624
|
*/
|
|
1575
|
-
var handleFieldComponentChange =
|
|
1625
|
+
var handleFieldComponentChange = useCallback(function (formData, newErrorSchema, id) {
|
|
1576
1626
|
var theId = id || fieldId;
|
|
1577
1627
|
return onChange(formData, newErrorSchema, theId);
|
|
1578
1628
|
}, [fieldId, onChange]);
|
|
@@ -1586,16 +1636,16 @@ function SchemaFieldRender(props) {
|
|
|
1586
1636
|
if (Object.keys(schema).length === 0) {
|
|
1587
1637
|
return null;
|
|
1588
1638
|
}
|
|
1589
|
-
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1639
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1590
1640
|
var _ref = errorSchema || {},
|
|
1591
1641
|
__errors = _ref.__errors,
|
|
1592
1642
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1593
1643
|
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1594
|
-
var fieldUiSchema = omit(uiSchema, [
|
|
1644
|
+
var fieldUiSchema = omit(uiSchema, ['ui:classNames', 'classNames', 'ui:style']);
|
|
1595
1645
|
if (UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1596
|
-
fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], [
|
|
1646
|
+
fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
1597
1647
|
}
|
|
1598
|
-
var field =
|
|
1648
|
+
var field = jsx(FieldComponent, _extends({}, props, {
|
|
1599
1649
|
onChange: handleFieldComponentChange,
|
|
1600
1650
|
idSchema: idSchema,
|
|
1601
1651
|
schema: schema,
|
|
@@ -1616,15 +1666,15 @@ function SchemaFieldRender(props) {
|
|
|
1616
1666
|
} else {
|
|
1617
1667
|
label = ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1618
1668
|
}
|
|
1619
|
-
var description = uiOptions.description || props.schema.description || schema.description ||
|
|
1669
|
+
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1620
1670
|
var help = uiOptions.help;
|
|
1621
|
-
var hidden = uiOptions.widget ===
|
|
1622
|
-
var classNames = [
|
|
1671
|
+
var hidden = uiOptions.widget === 'hidden';
|
|
1672
|
+
var classNames = ['form-group', 'field', "field-" + schema.type];
|
|
1623
1673
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1624
|
-
classNames.push(
|
|
1674
|
+
classNames.push('field-error has-error has-danger');
|
|
1625
1675
|
}
|
|
1626
1676
|
if (uiSchema !== null && uiSchema !== void 0 && uiSchema.classNames) {
|
|
1627
|
-
if (process.env.NODE_ENV !==
|
|
1677
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1628
1678
|
console.warn("'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead.");
|
|
1629
1679
|
}
|
|
1630
1680
|
classNames.push(uiSchema.classNames);
|
|
@@ -1632,7 +1682,7 @@ function SchemaFieldRender(props) {
|
|
|
1632
1682
|
if (uiOptions.classNames) {
|
|
1633
1683
|
classNames.push(uiOptions.classNames);
|
|
1634
1684
|
}
|
|
1635
|
-
var helpComponent =
|
|
1685
|
+
var helpComponent = jsx(FieldHelpTemplate, {
|
|
1636
1686
|
help: help,
|
|
1637
1687
|
idSchema: idSchema,
|
|
1638
1688
|
schema: schema,
|
|
@@ -1640,7 +1690,7 @@ function SchemaFieldRender(props) {
|
|
|
1640
1690
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
1641
1691
|
registry: registry
|
|
1642
1692
|
});
|
|
1643
|
-
var errorsComponent = hideError ? undefined :
|
|
1693
|
+
var errorsComponent = hideError ? undefined : jsx(FieldErrorTemplate, {
|
|
1644
1694
|
errors: __errors,
|
|
1645
1695
|
errorSchema: errorSchema,
|
|
1646
1696
|
idSchema: idSchema,
|
|
@@ -1649,7 +1699,7 @@ function SchemaFieldRender(props) {
|
|
|
1649
1699
|
registry: registry
|
|
1650
1700
|
});
|
|
1651
1701
|
var fieldProps = {
|
|
1652
|
-
description:
|
|
1702
|
+
description: jsx(DescriptionFieldTemplate, {
|
|
1653
1703
|
id: descriptionId(id),
|
|
1654
1704
|
description: description,
|
|
1655
1705
|
schema: schema,
|
|
@@ -1658,7 +1708,7 @@ function SchemaFieldRender(props) {
|
|
|
1658
1708
|
}),
|
|
1659
1709
|
rawDescription: description,
|
|
1660
1710
|
help: helpComponent,
|
|
1661
|
-
rawHelp: typeof help ===
|
|
1711
|
+
rawHelp: typeof help === 'string' ? help : undefined,
|
|
1662
1712
|
errors: errorsComponent,
|
|
1663
1713
|
rawErrors: hideError ? undefined : __errors,
|
|
1664
1714
|
id: id,
|
|
@@ -1672,7 +1722,7 @@ function SchemaFieldRender(props) {
|
|
|
1672
1722
|
readonly: readonly,
|
|
1673
1723
|
hideError: hideError,
|
|
1674
1724
|
displayLabel: displayLabel,
|
|
1675
|
-
classNames: classNames.join(
|
|
1725
|
+
classNames: classNames.join(' ').trim(),
|
|
1676
1726
|
style: uiOptions.style,
|
|
1677
1727
|
formContext: formContext,
|
|
1678
1728
|
formData: formData,
|
|
@@ -1682,68 +1732,72 @@ function SchemaFieldRender(props) {
|
|
|
1682
1732
|
};
|
|
1683
1733
|
var _AnyOfField = registry.fields.AnyOfField;
|
|
1684
1734
|
var _OneOfField = registry.fields.OneOfField;
|
|
1685
|
-
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[
|
|
1686
|
-
return
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1735
|
+
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:field']) && (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:fieldReplacesAnyOrOneOf']) === true;
|
|
1736
|
+
return jsx(FieldTemplate, _extends({}, fieldProps, {
|
|
1737
|
+
children: jsxs(Fragment, {
|
|
1738
|
+
children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsx(_AnyOfField, {
|
|
1739
|
+
name: name,
|
|
1740
|
+
disabled: disabled,
|
|
1741
|
+
readonly: readonly,
|
|
1742
|
+
hideError: hideError,
|
|
1743
|
+
errorSchema: errorSchema,
|
|
1744
|
+
formData: formData,
|
|
1745
|
+
formContext: formContext,
|
|
1746
|
+
idPrefix: idPrefix,
|
|
1747
|
+
idSchema: idSchema,
|
|
1748
|
+
idSeparator: idSeparator,
|
|
1749
|
+
onBlur: props.onBlur,
|
|
1750
|
+
onChange: props.onChange,
|
|
1751
|
+
onFocus: props.onFocus,
|
|
1752
|
+
options: schema.anyOf.map(function (_schema) {
|
|
1753
|
+
return schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData);
|
|
1754
|
+
}),
|
|
1755
|
+
baseType: schema.type,
|
|
1756
|
+
registry: registry,
|
|
1757
|
+
schema: schema,
|
|
1758
|
+
uiSchema: uiSchema
|
|
1759
|
+
}), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsx(_OneOfField, {
|
|
1760
|
+
name: name,
|
|
1761
|
+
disabled: disabled,
|
|
1762
|
+
readonly: readonly,
|
|
1763
|
+
hideError: hideError,
|
|
1764
|
+
errorSchema: errorSchema,
|
|
1765
|
+
formData: formData,
|
|
1766
|
+
formContext: formContext,
|
|
1767
|
+
idPrefix: idPrefix,
|
|
1768
|
+
idSchema: idSchema,
|
|
1769
|
+
idSeparator: idSeparator,
|
|
1770
|
+
onBlur: props.onBlur,
|
|
1771
|
+
onChange: props.onChange,
|
|
1772
|
+
onFocus: props.onFocus,
|
|
1773
|
+
options: schema.oneOf.map(function (_schema) {
|
|
1774
|
+
return schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData);
|
|
1775
|
+
}),
|
|
1776
|
+
baseType: schema.type,
|
|
1777
|
+
registry: registry,
|
|
1778
|
+
schema: schema,
|
|
1779
|
+
uiSchema: uiSchema
|
|
1780
|
+
})]
|
|
1781
|
+
})
|
|
1782
|
+
}));
|
|
1729
1783
|
}
|
|
1730
1784
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
1731
1785
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
1732
1786
|
*/
|
|
1733
|
-
var SchemaField = /*#__PURE__*/function (
|
|
1734
|
-
_inheritsLoose(SchemaField,
|
|
1787
|
+
var SchemaField = /*#__PURE__*/function (_Component) {
|
|
1788
|
+
_inheritsLoose(SchemaField, _Component);
|
|
1735
1789
|
function SchemaField() {
|
|
1736
|
-
return
|
|
1790
|
+
return _Component.apply(this, arguments) || this;
|
|
1737
1791
|
}
|
|
1738
1792
|
var _proto = SchemaField.prototype;
|
|
1739
1793
|
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
1740
1794
|
return !deepEquals(this.props, nextProps);
|
|
1741
1795
|
};
|
|
1742
1796
|
_proto.render = function render() {
|
|
1743
|
-
return
|
|
1797
|
+
return jsx(SchemaFieldRender, _extends({}, this.props));
|
|
1744
1798
|
};
|
|
1745
1799
|
return SchemaField;
|
|
1746
|
-
}(
|
|
1800
|
+
}(Component);
|
|
1747
1801
|
|
|
1748
1802
|
var _excluded$5 = ["widget", "placeholder"];
|
|
1749
1803
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
@@ -1774,7 +1828,7 @@ function StringField(props) {
|
|
|
1774
1828
|
formContext = registry.formContext,
|
|
1775
1829
|
schemaUtils = registry.schemaUtils;
|
|
1776
1830
|
var enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema) : undefined;
|
|
1777
|
-
var defaultWidget = enumOptions ?
|
|
1831
|
+
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1778
1832
|
if (format && hasWidget(schema, format, widgets)) {
|
|
1779
1833
|
defaultWidget = format;
|
|
1780
1834
|
}
|
|
@@ -1782,16 +1836,17 @@ function StringField(props) {
|
|
|
1782
1836
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1783
1837
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1784
1838
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1785
|
-
placeholder = _getUiOptions$placeho === void 0 ?
|
|
1839
|
+
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1786
1840
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1787
1841
|
var Widget = getWidget(schema, widget, widgets);
|
|
1788
|
-
return
|
|
1842
|
+
return jsx(Widget, {
|
|
1789
1843
|
options: _extends({}, options, {
|
|
1790
1844
|
enumOptions: enumOptions
|
|
1791
1845
|
}),
|
|
1792
1846
|
schema: schema,
|
|
1793
1847
|
uiSchema: uiSchema,
|
|
1794
1848
|
id: idSchema.$id,
|
|
1849
|
+
name: name,
|
|
1795
1850
|
label: title === undefined ? name : title,
|
|
1796
1851
|
value: formData,
|
|
1797
1852
|
onChange: onChange,
|
|
@@ -1856,8 +1911,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1856
1911
|
if (!description || !displayLabel) {
|
|
1857
1912
|
return null;
|
|
1858
1913
|
}
|
|
1859
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
1860
|
-
return
|
|
1914
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
1915
|
+
return jsx(DescriptionFieldTemplate, {
|
|
1861
1916
|
id: descriptionId(idSchema),
|
|
1862
1917
|
description: description,
|
|
1863
1918
|
schema: schema,
|
|
@@ -1878,13 +1933,16 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1878
1933
|
hasMoveDown = props.hasMoveDown,
|
|
1879
1934
|
hasMoveUp = props.hasMoveUp,
|
|
1880
1935
|
hasRemove = props.hasRemove,
|
|
1936
|
+
hasCopy = props.hasCopy,
|
|
1881
1937
|
index = props.index,
|
|
1938
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
1882
1939
|
onDropIndexClick = props.onDropIndexClick,
|
|
1883
1940
|
onReorderClick = props.onReorderClick,
|
|
1884
1941
|
readonly = props.readonly,
|
|
1885
1942
|
registry = props.registry,
|
|
1886
1943
|
uiSchema = props.uiSchema;
|
|
1887
1944
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
1945
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
1888
1946
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
1889
1947
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
1890
1948
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -1892,39 +1950,49 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1892
1950
|
flex: 1,
|
|
1893
1951
|
paddingLeft: 6,
|
|
1894
1952
|
paddingRight: 6,
|
|
1895
|
-
fontWeight:
|
|
1953
|
+
fontWeight: 'bold'
|
|
1896
1954
|
};
|
|
1897
|
-
return
|
|
1898
|
-
className: className
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1955
|
+
return jsxs("div", {
|
|
1956
|
+
className: className,
|
|
1957
|
+
children: [jsx("div", {
|
|
1958
|
+
className: hasToolbar ? 'col-xs-9' : 'col-xs-12',
|
|
1959
|
+
children: children
|
|
1960
|
+
}), hasToolbar && jsx("div", {
|
|
1961
|
+
className: 'col-xs-3 array-item-toolbox',
|
|
1962
|
+
children: jsxs("div", {
|
|
1963
|
+
className: 'btn-group',
|
|
1964
|
+
style: {
|
|
1965
|
+
display: 'flex',
|
|
1966
|
+
justifyContent: 'space-around'
|
|
1967
|
+
},
|
|
1968
|
+
children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
|
|
1969
|
+
style: btnStyle,
|
|
1970
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
1971
|
+
onClick: onReorderClick(index, index - 1),
|
|
1972
|
+
uiSchema: uiSchema,
|
|
1973
|
+
registry: registry
|
|
1974
|
+
}), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
|
|
1975
|
+
style: btnStyle,
|
|
1976
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
1977
|
+
onClick: onReorderClick(index, index + 1),
|
|
1978
|
+
uiSchema: uiSchema,
|
|
1979
|
+
registry: registry
|
|
1980
|
+
}), hasCopy && jsx(CopyButton, {
|
|
1981
|
+
style: btnStyle,
|
|
1982
|
+
disabled: disabled || readonly,
|
|
1983
|
+
onClick: onCopyIndexClick(index),
|
|
1984
|
+
uiSchema: uiSchema,
|
|
1985
|
+
registry: registry
|
|
1986
|
+
}), hasRemove && jsx(RemoveButton, {
|
|
1987
|
+
style: btnStyle,
|
|
1988
|
+
disabled: disabled || readonly,
|
|
1989
|
+
onClick: onDropIndexClick(index),
|
|
1990
|
+
uiSchema: uiSchema,
|
|
1991
|
+
registry: registry
|
|
1992
|
+
})]
|
|
1993
|
+
})
|
|
1994
|
+
})]
|
|
1995
|
+
});
|
|
1928
1996
|
}
|
|
1929
1997
|
|
|
1930
1998
|
var _excluded$4 = ["key"];
|
|
@@ -1946,42 +2014,42 @@ function ArrayFieldTemplate(props) {
|
|
|
1946
2014
|
schema = props.schema,
|
|
1947
2015
|
title = props.title;
|
|
1948
2016
|
var uiOptions = getUiOptions(uiSchema);
|
|
1949
|
-
var ArrayFieldDescriptionTemplate = getTemplate(
|
|
1950
|
-
var ArrayFieldItemTemplate = getTemplate(
|
|
1951
|
-
var ArrayFieldTitleTemplate = getTemplate(
|
|
2017
|
+
var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
2018
|
+
var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
2019
|
+
var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
1952
2020
|
// Button templates are not overridden in the uiSchema
|
|
1953
2021
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
1954
|
-
return
|
|
2022
|
+
return jsxs("fieldset", {
|
|
1955
2023
|
className: className,
|
|
1956
|
-
id: idSchema.$id
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
},
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
})
|
|
2024
|
+
id: idSchema.$id,
|
|
2025
|
+
children: [jsx(ArrayFieldTitleTemplate, {
|
|
2026
|
+
idSchema: idSchema,
|
|
2027
|
+
title: uiOptions.title || title,
|
|
2028
|
+
required: required,
|
|
2029
|
+
schema: schema,
|
|
2030
|
+
uiSchema: uiSchema,
|
|
2031
|
+
registry: registry
|
|
2032
|
+
}), jsx(ArrayFieldDescriptionTemplate, {
|
|
2033
|
+
idSchema: idSchema,
|
|
2034
|
+
description: uiOptions.description || schema.description,
|
|
2035
|
+
schema: schema,
|
|
2036
|
+
uiSchema: uiSchema,
|
|
2037
|
+
registry: registry
|
|
2038
|
+
}), jsx("div", {
|
|
2039
|
+
className: 'row array-item-list',
|
|
2040
|
+
children: items && items.map(function (_ref) {
|
|
2041
|
+
var key = _ref.key,
|
|
2042
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
2043
|
+
return jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
2044
|
+
})
|
|
2045
|
+
}), canAdd && jsx(AddButton, {
|
|
2046
|
+
className: 'array-item-add',
|
|
2047
|
+
onClick: onAddClick,
|
|
2048
|
+
disabled: disabled || readonly,
|
|
2049
|
+
uiSchema: uiSchema,
|
|
2050
|
+
registry: registry
|
|
2051
|
+
})]
|
|
2052
|
+
});
|
|
1985
2053
|
}
|
|
1986
2054
|
|
|
1987
2055
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
@@ -2002,8 +2070,8 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2002
2070
|
if (!title || !displayLabel) {
|
|
2003
2071
|
return null;
|
|
2004
2072
|
}
|
|
2005
|
-
var TitleFieldTemplate = getTemplate(
|
|
2006
|
-
return
|
|
2073
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
2074
|
+
return jsx(TitleFieldTemplate, {
|
|
2007
2075
|
id: titleId(idSchema),
|
|
2008
2076
|
title: title,
|
|
2009
2077
|
required: required,
|
|
@@ -2013,7 +2081,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2013
2081
|
});
|
|
2014
2082
|
}
|
|
2015
2083
|
|
|
2016
|
-
var _excluded$3 = ["id", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2084
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2017
2085
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2018
2086
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2019
2087
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2029,6 +2097,7 @@ function BaseInputTemplate(props) {
|
|
|
2029
2097
|
onBlur = props.onBlur,
|
|
2030
2098
|
onFocus = props.onFocus,
|
|
2031
2099
|
onChange = props.onChange,
|
|
2100
|
+
onChangeOverride = props.onChangeOverride,
|
|
2032
2101
|
options = props.options,
|
|
2033
2102
|
schema = props.schema,
|
|
2034
2103
|
type = props.type,
|
|
@@ -2036,19 +2105,19 @@ function BaseInputTemplate(props) {
|
|
|
2036
2105
|
// Note: since React 15.2.0 we can't forward unknown element attributes, so we
|
|
2037
2106
|
// exclude the "options" and "schema" ones here.
|
|
2038
2107
|
if (!id) {
|
|
2039
|
-
console.log(
|
|
2108
|
+
console.log('No id for', props);
|
|
2040
2109
|
throw new Error("no id for props " + JSON.stringify(props));
|
|
2041
2110
|
}
|
|
2042
2111
|
var inputProps = _extends({}, rest, getInputProps(schema, type, options));
|
|
2043
2112
|
var inputValue;
|
|
2044
|
-
if (inputProps.type ===
|
|
2045
|
-
inputValue = value || value === 0 ? value :
|
|
2113
|
+
if (inputProps.type === 'number' || inputProps.type === 'integer') {
|
|
2114
|
+
inputValue = value || value === 0 ? value : '';
|
|
2046
2115
|
} else {
|
|
2047
|
-
inputValue = value == null ?
|
|
2116
|
+
inputValue = value == null ? '' : value;
|
|
2048
2117
|
}
|
|
2049
2118
|
var _onChange = useCallback(function (_ref) {
|
|
2050
2119
|
var value = _ref.target.value;
|
|
2051
|
-
return onChange(value ===
|
|
2120
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
2052
2121
|
}, [onChange, options]);
|
|
2053
2122
|
var _onBlur = useCallback(function (_ref2) {
|
|
2054
2123
|
var value = _ref2.target.value;
|
|
@@ -2058,29 +2127,30 @@ function BaseInputTemplate(props) {
|
|
|
2058
2127
|
var value = _ref3.target.value;
|
|
2059
2128
|
return onFocus(id, value);
|
|
2060
2129
|
}, [onFocus, id]);
|
|
2061
|
-
return
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2130
|
+
return jsxs(Fragment, {
|
|
2131
|
+
children: [jsx("input", _extends({
|
|
2132
|
+
id: id,
|
|
2133
|
+
name: id,
|
|
2134
|
+
className: 'form-control',
|
|
2135
|
+
readOnly: readonly,
|
|
2136
|
+
disabled: disabled,
|
|
2137
|
+
autoFocus: autofocus,
|
|
2138
|
+
value: inputValue
|
|
2139
|
+
}, inputProps, {
|
|
2140
|
+
list: schema.examples ? examplesId(id) : undefined,
|
|
2141
|
+
onChange: onChangeOverride || _onChange,
|
|
2142
|
+
onBlur: _onBlur,
|
|
2143
|
+
onFocus: _onFocus,
|
|
2144
|
+
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
2145
|
+
})), Array.isArray(schema.examples) && jsx("datalist", {
|
|
2146
|
+
id: examplesId(id),
|
|
2147
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
2148
|
+
return jsx("option", {
|
|
2149
|
+
value: example
|
|
2150
|
+
}, example);
|
|
2151
|
+
})
|
|
2152
|
+
}, "datalist_" + id)]
|
|
2153
|
+
});
|
|
2084
2154
|
}
|
|
2085
2155
|
|
|
2086
2156
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -2095,53 +2165,67 @@ function SubmitButton(_ref) {
|
|
|
2095
2165
|
if (norender) {
|
|
2096
2166
|
return null;
|
|
2097
2167
|
}
|
|
2098
|
-
return
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2168
|
+
return jsx("div", {
|
|
2169
|
+
children: jsx("button", _extends({
|
|
2170
|
+
type: 'submit'
|
|
2171
|
+
}, submitButtonProps, {
|
|
2172
|
+
className: "btn btn-info " + submitButtonProps.className,
|
|
2173
|
+
children: submitText
|
|
2174
|
+
}))
|
|
2175
|
+
});
|
|
2103
2176
|
}
|
|
2104
2177
|
|
|
2105
2178
|
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2106
2179
|
function IconButton(props) {
|
|
2107
2180
|
var _props$iconType = props.iconType,
|
|
2108
|
-
iconType = _props$iconType === void 0 ?
|
|
2181
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
2109
2182
|
icon = props.icon,
|
|
2110
2183
|
className = props.className,
|
|
2111
2184
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
2112
|
-
return
|
|
2113
|
-
type:
|
|
2185
|
+
return jsx("button", _extends({
|
|
2186
|
+
type: 'button',
|
|
2114
2187
|
className: "btn btn-" + iconType + " " + className
|
|
2115
|
-
}, otherProps
|
|
2116
|
-
|
|
2188
|
+
}, otherProps, {
|
|
2189
|
+
children: jsx("i", {
|
|
2190
|
+
className: "glyphicon glyphicon-" + icon
|
|
2191
|
+
})
|
|
2192
|
+
}));
|
|
2193
|
+
}
|
|
2194
|
+
function CopyButton(props) {
|
|
2195
|
+
var translateString = props.registry.translateString;
|
|
2196
|
+
return jsx(IconButton, _extends({
|
|
2197
|
+
title: translateString(TranslatableString.CopyButton),
|
|
2198
|
+
className: 'array-item-copy'
|
|
2199
|
+
}, props, {
|
|
2200
|
+
icon: 'copy'
|
|
2117
2201
|
}));
|
|
2118
2202
|
}
|
|
2119
2203
|
function MoveDownButton(props) {
|
|
2120
2204
|
var translateString = props.registry.translateString;
|
|
2121
|
-
return
|
|
2205
|
+
return jsx(IconButton, _extends({
|
|
2122
2206
|
title: translateString(TranslatableString.MoveDownButton),
|
|
2123
|
-
className:
|
|
2207
|
+
className: 'array-item-move-down'
|
|
2124
2208
|
}, props, {
|
|
2125
|
-
icon:
|
|
2209
|
+
icon: 'arrow-down'
|
|
2126
2210
|
}));
|
|
2127
2211
|
}
|
|
2128
2212
|
function MoveUpButton(props) {
|
|
2129
2213
|
var translateString = props.registry.translateString;
|
|
2130
|
-
return
|
|
2214
|
+
return jsx(IconButton, _extends({
|
|
2131
2215
|
title: translateString(TranslatableString.MoveUpButton),
|
|
2132
|
-
className:
|
|
2216
|
+
className: 'array-item-move-up'
|
|
2133
2217
|
}, props, {
|
|
2134
|
-
icon:
|
|
2218
|
+
icon: 'arrow-up'
|
|
2135
2219
|
}));
|
|
2136
2220
|
}
|
|
2137
2221
|
function RemoveButton(props) {
|
|
2138
2222
|
var translateString = props.registry.translateString;
|
|
2139
|
-
return
|
|
2223
|
+
return jsx(IconButton, _extends({
|
|
2140
2224
|
title: translateString(TranslatableString.RemoveButton),
|
|
2141
|
-
className:
|
|
2225
|
+
className: 'array-item-remove'
|
|
2142
2226
|
}, props, {
|
|
2143
|
-
iconType:
|
|
2144
|
-
icon:
|
|
2227
|
+
iconType: 'danger',
|
|
2228
|
+
icon: 'remove'
|
|
2145
2229
|
}));
|
|
2146
2230
|
}
|
|
2147
2231
|
|
|
@@ -2153,25 +2237,28 @@ function AddButton(_ref) {
|
|
|
2153
2237
|
disabled = _ref.disabled,
|
|
2154
2238
|
registry = _ref.registry;
|
|
2155
2239
|
var translateString = registry.translateString;
|
|
2156
|
-
return
|
|
2157
|
-
className:
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2240
|
+
return jsx("div", {
|
|
2241
|
+
className: 'row',
|
|
2242
|
+
children: jsx("p", {
|
|
2243
|
+
className: "col-xs-3 col-xs-offset-9 text-right " + className,
|
|
2244
|
+
children: jsx(IconButton, {
|
|
2245
|
+
iconType: 'info',
|
|
2246
|
+
icon: 'plus',
|
|
2247
|
+
className: 'btn-add col-xs-12',
|
|
2248
|
+
title: translateString(TranslatableString.AddButton),
|
|
2249
|
+
onClick: onClick,
|
|
2250
|
+
disabled: disabled,
|
|
2251
|
+
registry: registry
|
|
2252
|
+
})
|
|
2253
|
+
})
|
|
2254
|
+
});
|
|
2169
2255
|
}
|
|
2170
2256
|
|
|
2171
2257
|
function buttonTemplates() {
|
|
2172
2258
|
return {
|
|
2173
2259
|
SubmitButton: SubmitButton,
|
|
2174
2260
|
AddButton: AddButton,
|
|
2261
|
+
CopyButton: CopyButton,
|
|
2175
2262
|
MoveDownButton: MoveDownButton,
|
|
2176
2263
|
MoveUpButton: MoveUpButton,
|
|
2177
2264
|
RemoveButton: RemoveButton
|
|
@@ -2188,16 +2275,18 @@ function DescriptionField(props) {
|
|
|
2188
2275
|
if (!description) {
|
|
2189
2276
|
return null;
|
|
2190
2277
|
}
|
|
2191
|
-
if (typeof description ===
|
|
2192
|
-
return
|
|
2278
|
+
if (typeof description === 'string') {
|
|
2279
|
+
return jsx("p", {
|
|
2193
2280
|
id: id,
|
|
2194
|
-
className:
|
|
2195
|
-
|
|
2281
|
+
className: 'field-description',
|
|
2282
|
+
children: description
|
|
2283
|
+
});
|
|
2196
2284
|
} else {
|
|
2197
|
-
return
|
|
2285
|
+
return jsx("div", {
|
|
2198
2286
|
id: id,
|
|
2199
|
-
className:
|
|
2200
|
-
|
|
2287
|
+
className: 'field-description',
|
|
2288
|
+
children: description
|
|
2289
|
+
});
|
|
2201
2290
|
}
|
|
2202
2291
|
}
|
|
2203
2292
|
|
|
@@ -2209,23 +2298,27 @@ function ErrorList(_ref) {
|
|
|
2209
2298
|
var errors = _ref.errors,
|
|
2210
2299
|
registry = _ref.registry;
|
|
2211
2300
|
var translateString = registry.translateString;
|
|
2212
|
-
return
|
|
2213
|
-
className:
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2301
|
+
return jsxs("div", {
|
|
2302
|
+
className: 'panel panel-danger errors',
|
|
2303
|
+
children: [jsx("div", {
|
|
2304
|
+
className: 'panel-heading',
|
|
2305
|
+
children: jsx("h3", {
|
|
2306
|
+
className: 'panel-title',
|
|
2307
|
+
children: translateString(TranslatableString.ErrorsLabel)
|
|
2308
|
+
})
|
|
2309
|
+
}), jsx("ul", {
|
|
2310
|
+
className: 'list-group',
|
|
2311
|
+
children: errors.map(function (error, i) {
|
|
2312
|
+
return jsx("li", {
|
|
2313
|
+
className: 'list-group-item text-danger',
|
|
2314
|
+
children: error.stack
|
|
2315
|
+
}, i);
|
|
2316
|
+
})
|
|
2317
|
+
})]
|
|
2318
|
+
});
|
|
2226
2319
|
}
|
|
2227
2320
|
|
|
2228
|
-
var REQUIRED_FIELD_SYMBOL$1 =
|
|
2321
|
+
var REQUIRED_FIELD_SYMBOL$1 = '*';
|
|
2229
2322
|
/** Renders a label for a field
|
|
2230
2323
|
*
|
|
2231
2324
|
* @param props - The `LabelProps` for this component
|
|
@@ -2237,12 +2330,14 @@ function Label(props) {
|
|
|
2237
2330
|
if (!label) {
|
|
2238
2331
|
return null;
|
|
2239
2332
|
}
|
|
2240
|
-
return
|
|
2241
|
-
className:
|
|
2242
|
-
htmlFor: id
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2333
|
+
return jsxs("label", {
|
|
2334
|
+
className: 'control-label',
|
|
2335
|
+
htmlFor: id,
|
|
2336
|
+
children: [label, required && jsx("span", {
|
|
2337
|
+
className: 'required',
|
|
2338
|
+
children: REQUIRED_FIELD_SYMBOL$1
|
|
2339
|
+
})]
|
|
2340
|
+
});
|
|
2246
2341
|
}
|
|
2247
2342
|
|
|
2248
2343
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -2263,17 +2358,20 @@ function FieldTemplate(props) {
|
|
|
2263
2358
|
registry = props.registry,
|
|
2264
2359
|
uiSchema = props.uiSchema;
|
|
2265
2360
|
var uiOptions = getUiOptions(uiSchema);
|
|
2266
|
-
var WrapIfAdditionalTemplate = getTemplate(
|
|
2361
|
+
var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
2267
2362
|
if (hidden) {
|
|
2268
|
-
return
|
|
2269
|
-
className:
|
|
2270
|
-
|
|
2363
|
+
return jsx("div", {
|
|
2364
|
+
className: 'hidden',
|
|
2365
|
+
children: children
|
|
2366
|
+
});
|
|
2271
2367
|
}
|
|
2272
|
-
return
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2368
|
+
return jsxs(WrapIfAdditionalTemplate, _extends({}, props, {
|
|
2369
|
+
children: [displayLabel && jsx(Label, {
|
|
2370
|
+
label: label,
|
|
2371
|
+
required: required,
|
|
2372
|
+
id: id
|
|
2373
|
+
}), displayLabel && description ? description : null, children, errors, help]
|
|
2374
|
+
}));
|
|
2277
2375
|
}
|
|
2278
2376
|
|
|
2279
2377
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -2288,17 +2386,20 @@ function FieldErrorTemplate(props) {
|
|
|
2288
2386
|
return null;
|
|
2289
2387
|
}
|
|
2290
2388
|
var id = errorId(idSchema);
|
|
2291
|
-
return
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2389
|
+
return jsx("div", {
|
|
2390
|
+
children: jsx("ul", {
|
|
2391
|
+
id: id,
|
|
2392
|
+
className: 'error-detail bs-callout bs-callout-info',
|
|
2393
|
+
children: errors.filter(function (elem) {
|
|
2394
|
+
return !!elem;
|
|
2395
|
+
}).map(function (error, index) {
|
|
2396
|
+
return jsx("li", {
|
|
2397
|
+
className: 'text-danger',
|
|
2398
|
+
children: error
|
|
2399
|
+
}, index);
|
|
2400
|
+
})
|
|
2401
|
+
})
|
|
2402
|
+
});
|
|
2302
2403
|
}
|
|
2303
2404
|
|
|
2304
2405
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -2312,16 +2413,18 @@ function FieldHelpTemplate(props) {
|
|
|
2312
2413
|
return null;
|
|
2313
2414
|
}
|
|
2314
2415
|
var id = helpId(idSchema);
|
|
2315
|
-
if (typeof help ===
|
|
2316
|
-
return
|
|
2416
|
+
if (typeof help === 'string') {
|
|
2417
|
+
return jsx("p", {
|
|
2317
2418
|
id: id,
|
|
2318
|
-
className:
|
|
2319
|
-
|
|
2419
|
+
className: 'help-block',
|
|
2420
|
+
children: help
|
|
2421
|
+
});
|
|
2320
2422
|
}
|
|
2321
|
-
return
|
|
2423
|
+
return jsx("div", {
|
|
2322
2424
|
id: id,
|
|
2323
|
-
className:
|
|
2324
|
-
|
|
2425
|
+
className: 'help-block',
|
|
2426
|
+
children: help
|
|
2427
|
+
});
|
|
2325
2428
|
}
|
|
2326
2429
|
|
|
2327
2430
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -2344,37 +2447,38 @@ function ObjectFieldTemplate(props) {
|
|
|
2344
2447
|
title = props.title,
|
|
2345
2448
|
uiSchema = props.uiSchema;
|
|
2346
2449
|
var options = getUiOptions(uiSchema);
|
|
2347
|
-
var TitleFieldTemplate = getTemplate(
|
|
2348
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
2450
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
2451
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2349
2452
|
// Button templates are not overridden in the uiSchema
|
|
2350
2453
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2351
|
-
return
|
|
2352
|
-
id: idSchema.$id
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2454
|
+
return jsxs("fieldset", {
|
|
2455
|
+
id: idSchema.$id,
|
|
2456
|
+
children: [(options.title || title) && jsx(TitleFieldTemplate, {
|
|
2457
|
+
id: titleId(idSchema),
|
|
2458
|
+
title: options.title || title,
|
|
2459
|
+
required: required,
|
|
2460
|
+
schema: schema,
|
|
2461
|
+
uiSchema: uiSchema,
|
|
2462
|
+
registry: registry
|
|
2463
|
+
}), (options.description || description) && jsx(DescriptionFieldTemplate, {
|
|
2464
|
+
id: descriptionId(idSchema),
|
|
2465
|
+
description: options.description || description,
|
|
2466
|
+
schema: schema,
|
|
2467
|
+
uiSchema: uiSchema,
|
|
2468
|
+
registry: registry
|
|
2469
|
+
}), properties.map(function (prop) {
|
|
2470
|
+
return prop.content;
|
|
2471
|
+
}), canExpand(schema, uiSchema, formData) && jsx(AddButton, {
|
|
2472
|
+
className: 'object-property-expand',
|
|
2473
|
+
onClick: onAddClick(schema),
|
|
2474
|
+
disabled: disabled || readonly,
|
|
2475
|
+
uiSchema: uiSchema,
|
|
2476
|
+
registry: registry
|
|
2477
|
+
})]
|
|
2478
|
+
});
|
|
2375
2479
|
}
|
|
2376
2480
|
|
|
2377
|
-
var REQUIRED_FIELD_SYMBOL =
|
|
2481
|
+
var REQUIRED_FIELD_SYMBOL = '*';
|
|
2378
2482
|
/** The `TitleField` is the template to use to render the title of a field
|
|
2379
2483
|
*
|
|
2380
2484
|
* @param props - The `TitleFieldProps` for this component
|
|
@@ -2383,11 +2487,13 @@ function TitleField(props) {
|
|
|
2383
2487
|
var id = props.id,
|
|
2384
2488
|
title = props.title,
|
|
2385
2489
|
required = props.required;
|
|
2386
|
-
return
|
|
2387
|
-
id: id
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2490
|
+
return jsxs("legend", {
|
|
2491
|
+
id: id,
|
|
2492
|
+
children: [title, required && jsx("span", {
|
|
2493
|
+
className: 'required',
|
|
2494
|
+
children: REQUIRED_FIELD_SYMBOL
|
|
2495
|
+
})]
|
|
2496
|
+
});
|
|
2391
2497
|
}
|
|
2392
2498
|
|
|
2393
2499
|
/** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
|
|
@@ -2411,9 +2517,16 @@ function UnsupportedField(props) {
|
|
|
2411
2517
|
translateEnum = translateEnum === TranslatableString.UnsupportedField ? TranslatableString.UnsupportedFieldWithReason : TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2412
2518
|
translateParams.push(reason);
|
|
2413
2519
|
}
|
|
2414
|
-
return
|
|
2415
|
-
className:
|
|
2416
|
-
|
|
2520
|
+
return jsxs("div", {
|
|
2521
|
+
className: 'unsupported-field',
|
|
2522
|
+
children: [jsx("p", {
|
|
2523
|
+
children: jsx(Markdown, {
|
|
2524
|
+
children: translateString(translateEnum, translateParams)
|
|
2525
|
+
})
|
|
2526
|
+
}), schema && jsx("pre", {
|
|
2527
|
+
children: JSON.stringify(schema, null, 2)
|
|
2528
|
+
})]
|
|
2529
|
+
});
|
|
2417
2530
|
}
|
|
2418
2531
|
|
|
2419
2532
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -2442,46 +2555,53 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2442
2555
|
var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
2443
2556
|
var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2444
2557
|
if (!additional) {
|
|
2445
|
-
return
|
|
2558
|
+
return jsx("div", {
|
|
2446
2559
|
className: classNames,
|
|
2447
|
-
style: style
|
|
2448
|
-
|
|
2560
|
+
style: style,
|
|
2561
|
+
children: children
|
|
2562
|
+
});
|
|
2449
2563
|
}
|
|
2450
|
-
return
|
|
2564
|
+
return jsx("div", {
|
|
2451
2565
|
className: classNames,
|
|
2452
|
-
style: style
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2566
|
+
style: style,
|
|
2567
|
+
children: jsxs("div", {
|
|
2568
|
+
className: 'row',
|
|
2569
|
+
children: [jsx("div", {
|
|
2570
|
+
className: 'col-xs-5 form-additional',
|
|
2571
|
+
children: jsxs("div", {
|
|
2572
|
+
className: 'form-group',
|
|
2573
|
+
children: [jsx(Label, {
|
|
2574
|
+
label: keyLabel,
|
|
2575
|
+
required: required,
|
|
2576
|
+
id: id + "-key"
|
|
2577
|
+
}), jsx("input", {
|
|
2578
|
+
className: 'form-control',
|
|
2579
|
+
type: 'text',
|
|
2580
|
+
id: id + "-key",
|
|
2581
|
+
onBlur: function onBlur(event) {
|
|
2582
|
+
return onKeyChange(event.target.value);
|
|
2583
|
+
},
|
|
2584
|
+
defaultValue: label
|
|
2585
|
+
})]
|
|
2586
|
+
})
|
|
2587
|
+
}), jsx("div", {
|
|
2588
|
+
className: 'form-additional form-group col-xs-5',
|
|
2589
|
+
children: children
|
|
2590
|
+
}), jsx("div", {
|
|
2591
|
+
className: 'col-xs-2',
|
|
2592
|
+
children: jsx(RemoveButton, {
|
|
2593
|
+
className: 'array-item-remove btn-block',
|
|
2594
|
+
style: {
|
|
2595
|
+
border: '0'
|
|
2596
|
+
},
|
|
2597
|
+
disabled: disabled || readonly,
|
|
2598
|
+
onClick: onDropPropertyClick(label),
|
|
2599
|
+
uiSchema: uiSchema,
|
|
2600
|
+
registry: registry
|
|
2601
|
+
})
|
|
2602
|
+
})]
|
|
2603
|
+
})
|
|
2604
|
+
});
|
|
2485
2605
|
}
|
|
2486
2606
|
|
|
2487
2607
|
function templates() {
|
|
@@ -2530,29 +2650,29 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
2530
2650
|
minute = state.minute,
|
|
2531
2651
|
second = state.second;
|
|
2532
2652
|
var data = [{
|
|
2533
|
-
type:
|
|
2653
|
+
type: 'year',
|
|
2534
2654
|
range: yearsRange,
|
|
2535
2655
|
value: year
|
|
2536
2656
|
}, {
|
|
2537
|
-
type:
|
|
2657
|
+
type: 'month',
|
|
2538
2658
|
range: [1, 12],
|
|
2539
2659
|
value: month
|
|
2540
2660
|
}, {
|
|
2541
|
-
type:
|
|
2661
|
+
type: 'day',
|
|
2542
2662
|
range: [1, 31],
|
|
2543
2663
|
value: day
|
|
2544
2664
|
}];
|
|
2545
2665
|
if (time) {
|
|
2546
2666
|
data.push({
|
|
2547
|
-
type:
|
|
2667
|
+
type: 'hour',
|
|
2548
2668
|
range: [0, 23],
|
|
2549
2669
|
value: hour
|
|
2550
2670
|
}, {
|
|
2551
|
-
type:
|
|
2671
|
+
type: 'minute',
|
|
2552
2672
|
range: [0, 59],
|
|
2553
2673
|
value: minute
|
|
2554
2674
|
}, {
|
|
2555
|
-
type:
|
|
2675
|
+
type: 'second',
|
|
2556
2676
|
range: [0, 59],
|
|
2557
2677
|
value: second
|
|
2558
2678
|
});
|
|
@@ -2565,20 +2685,22 @@ function DateElement(_ref) {
|
|
|
2565
2685
|
value = _ref.value,
|
|
2566
2686
|
select = _ref.select,
|
|
2567
2687
|
rootId = _ref.rootId,
|
|
2688
|
+
name = _ref.name,
|
|
2568
2689
|
disabled = _ref.disabled,
|
|
2569
2690
|
readonly = _ref.readonly,
|
|
2570
2691
|
autofocus = _ref.autofocus,
|
|
2571
2692
|
registry = _ref.registry,
|
|
2572
2693
|
onBlur = _ref.onBlur,
|
|
2573
2694
|
onFocus = _ref.onFocus;
|
|
2574
|
-
var id = rootId +
|
|
2695
|
+
var id = rootId + '_' + type;
|
|
2575
2696
|
var SelectWidget = registry.widgets.SelectWidget;
|
|
2576
|
-
return
|
|
2697
|
+
return jsx(SelectWidget, {
|
|
2577
2698
|
schema: {
|
|
2578
|
-
type:
|
|
2699
|
+
type: 'integer'
|
|
2579
2700
|
},
|
|
2580
2701
|
id: id,
|
|
2581
|
-
|
|
2702
|
+
name: name,
|
|
2703
|
+
className: 'form-control',
|
|
2582
2704
|
options: {
|
|
2583
2705
|
enumOptions: rangeOptions(range[0], range[1])
|
|
2584
2706
|
},
|
|
@@ -2593,7 +2715,7 @@ function DateElement(_ref) {
|
|
|
2593
2715
|
onBlur: onBlur,
|
|
2594
2716
|
onFocus: onFocus,
|
|
2595
2717
|
registry: registry,
|
|
2596
|
-
label:
|
|
2718
|
+
label: '',
|
|
2597
2719
|
"aria-describedby": ariaDescribedByIds(rootId)
|
|
2598
2720
|
});
|
|
2599
2721
|
}
|
|
@@ -2611,6 +2733,7 @@ function AltDateWidget(_ref2) {
|
|
|
2611
2733
|
autofocus = _ref2$autofocus === void 0 ? false : _ref2$autofocus,
|
|
2612
2734
|
options = _ref2.options,
|
|
2613
2735
|
id = _ref2.id,
|
|
2736
|
+
name = _ref2.name,
|
|
2614
2737
|
registry = _ref2.registry,
|
|
2615
2738
|
onBlur = _ref2.onBlur,
|
|
2616
2739
|
onFocus = _ref2.onFocus,
|
|
@@ -2650,39 +2773,45 @@ function AltDateWidget(_ref2) {
|
|
|
2650
2773
|
if (disabled || readonly) {
|
|
2651
2774
|
return;
|
|
2652
2775
|
}
|
|
2653
|
-
setState(parseDateString(
|
|
2776
|
+
setState(parseDateString('', time));
|
|
2654
2777
|
onChange(undefined);
|
|
2655
2778
|
}, [disabled, readonly, time, onChange]);
|
|
2656
|
-
return
|
|
2657
|
-
className:
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2779
|
+
return jsxs("ul", {
|
|
2780
|
+
className: 'list-inline',
|
|
2781
|
+
children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2782
|
+
return jsx("li", {
|
|
2783
|
+
className: 'list-inline-item',
|
|
2784
|
+
children: jsx(DateElement, _extends({
|
|
2785
|
+
rootId: id,
|
|
2786
|
+
name: name,
|
|
2787
|
+
select: handleChange
|
|
2788
|
+
}, elemProps, {
|
|
2789
|
+
disabled: disabled,
|
|
2790
|
+
readonly: readonly,
|
|
2791
|
+
registry: registry,
|
|
2792
|
+
onBlur: onBlur,
|
|
2793
|
+
onFocus: onFocus,
|
|
2794
|
+
autofocus: autofocus && i === 0
|
|
2795
|
+
}))
|
|
2796
|
+
}, i);
|
|
2797
|
+
}), (options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && jsx("li", {
|
|
2798
|
+
className: 'list-inline-item',
|
|
2799
|
+
children: jsx("a", {
|
|
2800
|
+
href: '#',
|
|
2801
|
+
className: 'btn btn-info btn-now',
|
|
2802
|
+
onClick: handleSetNow,
|
|
2803
|
+
children: translateString(TranslatableString.NowLabel)
|
|
2804
|
+
})
|
|
2805
|
+
}), (options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && jsx("li", {
|
|
2806
|
+
className: 'list-inline-item',
|
|
2807
|
+
children: jsx("a", {
|
|
2808
|
+
href: '#',
|
|
2809
|
+
className: 'btn btn-warning btn-clear',
|
|
2810
|
+
onClick: handleClear,
|
|
2811
|
+
children: translateString(TranslatableString.ClearLabel)
|
|
2812
|
+
})
|
|
2813
|
+
})]
|
|
2814
|
+
});
|
|
2686
2815
|
}
|
|
2687
2816
|
|
|
2688
2817
|
var _excluded$1 = ["time"];
|
|
@@ -2696,7 +2825,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2696
2825
|
time = _ref$time === void 0 ? true : _ref$time,
|
|
2697
2826
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2698
2827
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
2699
|
-
return
|
|
2828
|
+
return jsx(AltDateWidget, _extends({
|
|
2700
2829
|
time: time
|
|
2701
2830
|
}, props));
|
|
2702
2831
|
}
|
|
@@ -2721,7 +2850,7 @@ function CheckboxWidget(_ref) {
|
|
|
2721
2850
|
onFocus = _ref.onFocus,
|
|
2722
2851
|
onChange = _ref.onChange,
|
|
2723
2852
|
registry = _ref.registry;
|
|
2724
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
2853
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2725
2854
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
2726
2855
|
// the "required" attribute if the field value must be "true", due to the
|
|
2727
2856
|
// "const" or "enum" keywords
|
|
@@ -2735,27 +2864,32 @@ function CheckboxWidget(_ref) {
|
|
|
2735
2864
|
var handleFocus = useCallback(function (event) {
|
|
2736
2865
|
return onFocus(id, event.target.checked);
|
|
2737
2866
|
}, [onFocus, id]);
|
|
2738
|
-
return
|
|
2739
|
-
className: "checkbox " + (disabled || readonly ?
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2867
|
+
return jsxs("div", {
|
|
2868
|
+
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2869
|
+
children: [schema.description && jsx(DescriptionFieldTemplate, {
|
|
2870
|
+
id: descriptionId(id),
|
|
2871
|
+
description: schema.description,
|
|
2872
|
+
schema: schema,
|
|
2873
|
+
uiSchema: uiSchema,
|
|
2874
|
+
registry: registry
|
|
2875
|
+
}), jsxs("label", {
|
|
2876
|
+
children: [jsx("input", {
|
|
2877
|
+
type: 'checkbox',
|
|
2878
|
+
id: id,
|
|
2879
|
+
name: id,
|
|
2880
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
2881
|
+
required: required,
|
|
2882
|
+
disabled: disabled || readonly,
|
|
2883
|
+
autoFocus: autofocus,
|
|
2884
|
+
onChange: handleChange,
|
|
2885
|
+
onBlur: handleBlur,
|
|
2886
|
+
onFocus: handleFocus,
|
|
2887
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
2888
|
+
}), jsx("span", {
|
|
2889
|
+
children: label
|
|
2890
|
+
})]
|
|
2891
|
+
})]
|
|
2892
|
+
});
|
|
2759
2893
|
}
|
|
2760
2894
|
|
|
2761
2895
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
@@ -2788,41 +2922,48 @@ function CheckboxesWidget(_ref) {
|
|
|
2788
2922
|
var value = _ref3.target.value;
|
|
2789
2923
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2790
2924
|
}, [onFocus, id]);
|
|
2791
|
-
return
|
|
2792
|
-
className:
|
|
2793
|
-
id: id
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2925
|
+
return jsx("div", {
|
|
2926
|
+
className: 'checkboxes',
|
|
2927
|
+
id: id,
|
|
2928
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2929
|
+
var checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
2930
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2931
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
2932
|
+
var handleChange = function handleChange(event) {
|
|
2933
|
+
if (event.target.checked) {
|
|
2934
|
+
onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
2935
|
+
} else {
|
|
2936
|
+
onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
2937
|
+
}
|
|
2938
|
+
};
|
|
2939
|
+
var checkbox = jsxs("span", {
|
|
2940
|
+
children: [jsx("input", {
|
|
2941
|
+
type: 'checkbox',
|
|
2942
|
+
id: optionId(id, index),
|
|
2943
|
+
name: id,
|
|
2944
|
+
checked: checked,
|
|
2945
|
+
value: String(index),
|
|
2946
|
+
disabled: disabled || itemDisabled || readonly,
|
|
2947
|
+
autoFocus: autofocus && index === 0,
|
|
2948
|
+
onChange: handleChange,
|
|
2949
|
+
onBlur: handleBlur,
|
|
2950
|
+
onFocus: handleFocus,
|
|
2951
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
2952
|
+
}), jsx("span", {
|
|
2953
|
+
children: option.label
|
|
2954
|
+
})]
|
|
2955
|
+
});
|
|
2956
|
+
return inline ? jsx("label", {
|
|
2957
|
+
className: "checkbox-inline " + disabledCls,
|
|
2958
|
+
children: checkbox
|
|
2959
|
+
}, index) : jsx("div", {
|
|
2960
|
+
className: "checkbox " + disabledCls,
|
|
2961
|
+
children: jsx("label", {
|
|
2962
|
+
children: checkbox
|
|
2963
|
+
})
|
|
2964
|
+
}, index);
|
|
2965
|
+
})
|
|
2966
|
+
});
|
|
2826
2967
|
}
|
|
2827
2968
|
|
|
2828
2969
|
/** The `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
|
|
@@ -2835,9 +2976,9 @@ function ColorWidget(props) {
|
|
|
2835
2976
|
readonly = props.readonly,
|
|
2836
2977
|
options = props.options,
|
|
2837
2978
|
registry = props.registry;
|
|
2838
|
-
var BaseInputTemplate = getTemplate(
|
|
2839
|
-
return
|
|
2840
|
-
type:
|
|
2979
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2980
|
+
return jsx(BaseInputTemplate, _extends({
|
|
2981
|
+
type: 'color'
|
|
2841
2982
|
}, props, {
|
|
2842
2983
|
disabled: disabled || readonly
|
|
2843
2984
|
}));
|
|
@@ -2852,12 +2993,12 @@ function DateWidget(props) {
|
|
|
2852
2993
|
var onChange = props.onChange,
|
|
2853
2994
|
options = props.options,
|
|
2854
2995
|
registry = props.registry;
|
|
2855
|
-
var BaseInputTemplate = getTemplate(
|
|
2996
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2856
2997
|
var handleChange = useCallback(function (value) {
|
|
2857
2998
|
return onChange(value || undefined);
|
|
2858
2999
|
}, [onChange]);
|
|
2859
|
-
return
|
|
2860
|
-
type:
|
|
3000
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3001
|
+
type: 'date'
|
|
2861
3002
|
}, props, {
|
|
2862
3003
|
onChange: handleChange
|
|
2863
3004
|
}));
|
|
@@ -2873,9 +3014,9 @@ function DateTimeWidget(props) {
|
|
|
2873
3014
|
value = props.value,
|
|
2874
3015
|
options = props.options,
|
|
2875
3016
|
registry = props.registry;
|
|
2876
|
-
var BaseInputTemplate = getTemplate(
|
|
2877
|
-
return
|
|
2878
|
-
type:
|
|
3017
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3018
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3019
|
+
type: 'datetime-local'
|
|
2879
3020
|
}, props, {
|
|
2880
3021
|
value: utcToLocal(value),
|
|
2881
3022
|
onChange: function onChange(value) {
|
|
@@ -2891,9 +3032,9 @@ function DateTimeWidget(props) {
|
|
|
2891
3032
|
function EmailWidget(props) {
|
|
2892
3033
|
var options = props.options,
|
|
2893
3034
|
registry = props.registry;
|
|
2894
|
-
var BaseInputTemplate = getTemplate(
|
|
2895
|
-
return
|
|
2896
|
-
type:
|
|
3035
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3036
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3037
|
+
type: 'email'
|
|
2897
3038
|
}, props));
|
|
2898
3039
|
}
|
|
2899
3040
|
|
|
@@ -2901,7 +3042,7 @@ function addNameToDataURL(dataURL, name) {
|
|
|
2901
3042
|
if (dataURL === null) {
|
|
2902
3043
|
return null;
|
|
2903
3044
|
}
|
|
2904
|
-
return dataURL.replace(
|
|
3045
|
+
return dataURL.replace(';base64', ";name=" + encodeURIComponent(name) + ";base64");
|
|
2905
3046
|
}
|
|
2906
3047
|
function processFile(file) {
|
|
2907
3048
|
var name = file.name,
|
|
@@ -2912,7 +3053,7 @@ function processFile(file) {
|
|
|
2912
3053
|
reader.onerror = reject;
|
|
2913
3054
|
reader.onload = function (event) {
|
|
2914
3055
|
var _event$target;
|
|
2915
|
-
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) ===
|
|
3056
|
+
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) === 'string') {
|
|
2916
3057
|
resolve({
|
|
2917
3058
|
dataURL: addNameToDataURL(event.target.result, name),
|
|
2918
3059
|
name: name,
|
|
@@ -2941,20 +3082,23 @@ function FilesInfo(_ref) {
|
|
|
2941
3082
|
return null;
|
|
2942
3083
|
}
|
|
2943
3084
|
var translateString = registry.translateString;
|
|
2944
|
-
return
|
|
2945
|
-
className:
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
3085
|
+
return jsx("ul", {
|
|
3086
|
+
className: 'file-info',
|
|
3087
|
+
children: filesInfo.map(function (fileInfo, key) {
|
|
3088
|
+
var name = fileInfo.name,
|
|
3089
|
+
size = fileInfo.size,
|
|
3090
|
+
type = fileInfo.type;
|
|
3091
|
+
return jsx("li", {
|
|
3092
|
+
children: jsx(Markdown, {
|
|
3093
|
+
children: translateString(TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3094
|
+
})
|
|
3095
|
+
}, key);
|
|
3096
|
+
})
|
|
3097
|
+
});
|
|
2954
3098
|
}
|
|
2955
3099
|
function extractFileInfo(dataURLs) {
|
|
2956
3100
|
return dataURLs.filter(function (dataURL) {
|
|
2957
|
-
return
|
|
3101
|
+
return dataURL;
|
|
2958
3102
|
}).map(function (dataURL) {
|
|
2959
3103
|
var _dataURItoBlob = dataURItoBlob(dataURL),
|
|
2960
3104
|
blob = _dataURItoBlob.blob,
|
|
@@ -2970,17 +3114,15 @@ function extractFileInfo(dataURLs) {
|
|
|
2970
3114
|
* The `FileWidget` is a widget for rendering file upload fields.
|
|
2971
3115
|
* It is typically used with a string property with data-url format.
|
|
2972
3116
|
*/
|
|
2973
|
-
function FileWidget(
|
|
2974
|
-
var
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
options = _ref2.options,
|
|
2983
|
-
registry = _ref2.registry;
|
|
3117
|
+
function FileWidget(props) {
|
|
3118
|
+
var disabled = props.disabled,
|
|
3119
|
+
readonly = props.readonly,
|
|
3120
|
+
multiple = props.multiple,
|
|
3121
|
+
onChange = props.onChange,
|
|
3122
|
+
value = props.value,
|
|
3123
|
+
options = props.options,
|
|
3124
|
+
registry = props.registry;
|
|
3125
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2984
3126
|
var extractedFilesInfo = useMemo(function () {
|
|
2985
3127
|
return Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value]);
|
|
2986
3128
|
}, [value]);
|
|
@@ -3003,21 +3145,18 @@ function FileWidget(_ref2) {
|
|
|
3003
3145
|
}
|
|
3004
3146
|
});
|
|
3005
3147
|
}, [multiple, onChange]);
|
|
3006
|
-
return
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
})
|
|
3018
|
-
filesInfo: filesInfo,
|
|
3019
|
-
registry: registry
|
|
3020
|
-
}));
|
|
3148
|
+
return jsxs("div", {
|
|
3149
|
+
children: [jsx(BaseInputTemplate, _extends({}, props, {
|
|
3150
|
+
disabled: disabled || readonly,
|
|
3151
|
+
type: 'file',
|
|
3152
|
+
onChangeOverride: handleChange,
|
|
3153
|
+
value: '',
|
|
3154
|
+
accept: options.accept ? String(options.accept) : undefined
|
|
3155
|
+
})), jsx(FilesInfo, {
|
|
3156
|
+
filesInfo: filesInfo,
|
|
3157
|
+
registry: registry
|
|
3158
|
+
})]
|
|
3159
|
+
});
|
|
3021
3160
|
}
|
|
3022
3161
|
|
|
3023
3162
|
/** The `HiddenWidget` is a widget for rendering a hidden input field.
|
|
@@ -3028,11 +3167,11 @@ function FileWidget(_ref2) {
|
|
|
3028
3167
|
function HiddenWidget(_ref) {
|
|
3029
3168
|
var id = _ref.id,
|
|
3030
3169
|
value = _ref.value;
|
|
3031
|
-
return
|
|
3032
|
-
type:
|
|
3170
|
+
return jsx("input", {
|
|
3171
|
+
type: 'hidden',
|
|
3033
3172
|
id: id,
|
|
3034
3173
|
name: id,
|
|
3035
|
-
value: typeof value ===
|
|
3174
|
+
value: typeof value === 'undefined' ? '' : value
|
|
3036
3175
|
});
|
|
3037
3176
|
}
|
|
3038
3177
|
|
|
@@ -3043,9 +3182,9 @@ function HiddenWidget(_ref) {
|
|
|
3043
3182
|
function PasswordWidget(props) {
|
|
3044
3183
|
var options = props.options,
|
|
3045
3184
|
registry = props.registry;
|
|
3046
|
-
var BaseInputTemplate = getTemplate(
|
|
3047
|
-
return
|
|
3048
|
-
type:
|
|
3185
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3186
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3187
|
+
type: 'password'
|
|
3049
3188
|
}, props));
|
|
3050
3189
|
}
|
|
3051
3190
|
|
|
@@ -3080,38 +3219,45 @@ function RadioWidget(_ref) {
|
|
|
3080
3219
|
var value = _ref3.target.value;
|
|
3081
3220
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3082
3221
|
}, [onFocus, id]);
|
|
3083
|
-
return
|
|
3084
|
-
className:
|
|
3085
|
-
id: id
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3222
|
+
return jsx("div", {
|
|
3223
|
+
className: 'field-radio-group',
|
|
3224
|
+
id: id,
|
|
3225
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
3226
|
+
var checked = enumOptionsIsSelected(option.value, value);
|
|
3227
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3228
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
3229
|
+
var handleChange = function handleChange() {
|
|
3230
|
+
return onChange(option.value);
|
|
3231
|
+
};
|
|
3232
|
+
var radio = jsxs("span", {
|
|
3233
|
+
children: [jsx("input", {
|
|
3234
|
+
type: 'radio',
|
|
3235
|
+
id: optionId(id, i),
|
|
3236
|
+
checked: checked,
|
|
3237
|
+
name: name,
|
|
3238
|
+
required: required,
|
|
3239
|
+
value: String(i),
|
|
3240
|
+
disabled: disabled || itemDisabled || readonly,
|
|
3241
|
+
autoFocus: autofocus && i === 0,
|
|
3242
|
+
onChange: handleChange,
|
|
3243
|
+
onBlur: handleBlur,
|
|
3244
|
+
onFocus: handleFocus,
|
|
3245
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
3246
|
+
}), jsx("span", {
|
|
3247
|
+
children: option.label
|
|
3248
|
+
})]
|
|
3249
|
+
});
|
|
3250
|
+
return inline ? jsx("label", {
|
|
3251
|
+
className: "radio-inline " + disabledCls,
|
|
3252
|
+
children: radio
|
|
3253
|
+
}, i) : jsx("div", {
|
|
3254
|
+
className: "radio " + disabledCls,
|
|
3255
|
+
children: jsx("label", {
|
|
3256
|
+
children: radio
|
|
3257
|
+
})
|
|
3258
|
+
}, i);
|
|
3259
|
+
})
|
|
3260
|
+
});
|
|
3115
3261
|
}
|
|
3116
3262
|
|
|
3117
3263
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -3122,13 +3268,15 @@ function RadioWidget(_ref) {
|
|
|
3122
3268
|
function RangeWidget(props) {
|
|
3123
3269
|
var value = props.value,
|
|
3124
3270
|
BaseInputTemplate = props.registry.templates.BaseInputTemplate;
|
|
3125
|
-
return
|
|
3126
|
-
className:
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3271
|
+
return jsxs("div", {
|
|
3272
|
+
className: 'field-range-wrapper',
|
|
3273
|
+
children: [jsx(BaseInputTemplate, _extends({
|
|
3274
|
+
type: 'range'
|
|
3275
|
+
}, props)), jsx("span", {
|
|
3276
|
+
className: 'range-view',
|
|
3277
|
+
children: value
|
|
3278
|
+
})]
|
|
3279
|
+
});
|
|
3132
3280
|
}
|
|
3133
3281
|
|
|
3134
3282
|
function getValue(event, multiple) {
|
|
@@ -3165,7 +3313,7 @@ function SelectWidget(_ref) {
|
|
|
3165
3313
|
var enumOptions = options.enumOptions,
|
|
3166
3314
|
enumDisabled = options.enumDisabled,
|
|
3167
3315
|
optEmptyVal = options.emptyValue;
|
|
3168
|
-
var emptyValue = multiple ? [] :
|
|
3316
|
+
var emptyValue = multiple ? [] : '';
|
|
3169
3317
|
var handleFocus = useCallback(function (event) {
|
|
3170
3318
|
var newValue = getValue(event, multiple);
|
|
3171
3319
|
return onFocus(id, enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
@@ -3179,31 +3327,33 @@ function SelectWidget(_ref) {
|
|
|
3179
3327
|
return onChange(enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3180
3328
|
}, [onChange, schema, multiple, options]);
|
|
3181
3329
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
3182
|
-
return
|
|
3330
|
+
return jsxs("select", {
|
|
3183
3331
|
id: id,
|
|
3184
3332
|
name: id,
|
|
3185
3333
|
multiple: multiple,
|
|
3186
|
-
className:
|
|
3187
|
-
value: typeof selectedIndexes ===
|
|
3334
|
+
className: 'form-control',
|
|
3335
|
+
value: typeof selectedIndexes === 'undefined' ? emptyValue : selectedIndexes,
|
|
3188
3336
|
required: required,
|
|
3189
3337
|
disabled: disabled || readonly,
|
|
3190
3338
|
autoFocus: autofocus,
|
|
3191
3339
|
onBlur: handleBlur,
|
|
3192
3340
|
onFocus: handleFocus,
|
|
3193
3341
|
onChange: handleChange,
|
|
3194
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3342
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
3343
|
+
children: [!multiple && schema["default"] === undefined && jsx("option", {
|
|
3344
|
+
value: '',
|
|
3345
|
+
children: placeholder
|
|
3346
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
3347
|
+
var value = _ref2.value,
|
|
3348
|
+
label = _ref2.label;
|
|
3349
|
+
var disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
|
|
3350
|
+
return jsx("option", {
|
|
3351
|
+
value: String(i),
|
|
3352
|
+
disabled: disabled,
|
|
3353
|
+
children: label
|
|
3354
|
+
}, i);
|
|
3355
|
+
})]
|
|
3356
|
+
});
|
|
3207
3357
|
}
|
|
3208
3358
|
|
|
3209
3359
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -3226,7 +3376,7 @@ function TextareaWidget(_ref) {
|
|
|
3226
3376
|
onFocus = _ref.onFocus;
|
|
3227
3377
|
var handleChange = useCallback(function (_ref2) {
|
|
3228
3378
|
var value = _ref2.target.value;
|
|
3229
|
-
return onChange(value ===
|
|
3379
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
3230
3380
|
}, [onChange, options.emptyValue]);
|
|
3231
3381
|
var handleBlur = useCallback(function (_ref3) {
|
|
3232
3382
|
var value = _ref3.target.value;
|
|
@@ -3236,11 +3386,11 @@ function TextareaWidget(_ref) {
|
|
|
3236
3386
|
var value = _ref4.target.value;
|
|
3237
3387
|
return onFocus(id, value);
|
|
3238
3388
|
}, [id, onFocus]);
|
|
3239
|
-
return
|
|
3389
|
+
return jsx("textarea", {
|
|
3240
3390
|
id: id,
|
|
3241
3391
|
name: id,
|
|
3242
|
-
className:
|
|
3243
|
-
value: value ? value :
|
|
3392
|
+
className: 'form-control',
|
|
3393
|
+
value: value ? value : '',
|
|
3244
3394
|
placeholder: placeholder,
|
|
3245
3395
|
required: required,
|
|
3246
3396
|
disabled: disabled,
|
|
@@ -3265,8 +3415,28 @@ TextareaWidget.defaultProps = {
|
|
|
3265
3415
|
function TextWidget(props) {
|
|
3266
3416
|
var options = props.options,
|
|
3267
3417
|
registry = props.registry;
|
|
3268
|
-
var BaseInputTemplate = getTemplate(
|
|
3269
|
-
return
|
|
3418
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3419
|
+
return jsx(BaseInputTemplate, _extends({}, props));
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
/** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
|
|
3423
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
3424
|
+
*
|
|
3425
|
+
* @param props - The `WidgetProps` for this component
|
|
3426
|
+
*/
|
|
3427
|
+
function TimeWidget(props) {
|
|
3428
|
+
var onChange = props.onChange,
|
|
3429
|
+
options = props.options,
|
|
3430
|
+
registry = props.registry;
|
|
3431
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3432
|
+
var handleChange = useCallback(function (value) {
|
|
3433
|
+
return onChange(value ? value + ":00" : undefined);
|
|
3434
|
+
}, [onChange]);
|
|
3435
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3436
|
+
type: 'time'
|
|
3437
|
+
}, props, {
|
|
3438
|
+
onChange: handleChange
|
|
3439
|
+
}));
|
|
3270
3440
|
}
|
|
3271
3441
|
|
|
3272
3442
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
@@ -3276,9 +3446,9 @@ function TextWidget(props) {
|
|
|
3276
3446
|
function URLWidget(props) {
|
|
3277
3447
|
var options = props.options,
|
|
3278
3448
|
registry = props.registry;
|
|
3279
|
-
var BaseInputTemplate = getTemplate(
|
|
3280
|
-
return
|
|
3281
|
-
type:
|
|
3449
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3450
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3451
|
+
type: 'url'
|
|
3282
3452
|
}, props));
|
|
3283
3453
|
}
|
|
3284
3454
|
|
|
@@ -3289,32 +3459,33 @@ function URLWidget(props) {
|
|
|
3289
3459
|
function UpDownWidget(props) {
|
|
3290
3460
|
var options = props.options,
|
|
3291
3461
|
registry = props.registry;
|
|
3292
|
-
var BaseInputTemplate = getTemplate(
|
|
3293
|
-
return
|
|
3294
|
-
type:
|
|
3462
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3463
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3464
|
+
type: 'number'
|
|
3295
3465
|
}, props));
|
|
3296
3466
|
}
|
|
3297
3467
|
|
|
3298
3468
|
function widgets() {
|
|
3299
3469
|
return {
|
|
3470
|
+
AltDateWidget: AltDateWidget,
|
|
3471
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
3472
|
+
CheckboxWidget: CheckboxWidget,
|
|
3473
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
3474
|
+
ColorWidget: ColorWidget,
|
|
3475
|
+
DateWidget: DateWidget,
|
|
3476
|
+
DateTimeWidget: DateTimeWidget,
|
|
3477
|
+
EmailWidget: EmailWidget,
|
|
3478
|
+
FileWidget: FileWidget,
|
|
3479
|
+
HiddenWidget: HiddenWidget,
|
|
3300
3480
|
PasswordWidget: PasswordWidget,
|
|
3301
3481
|
RadioWidget: RadioWidget,
|
|
3302
|
-
UpDownWidget: UpDownWidget,
|
|
3303
3482
|
RangeWidget: RangeWidget,
|
|
3304
3483
|
SelectWidget: SelectWidget,
|
|
3305
3484
|
TextWidget: TextWidget,
|
|
3306
|
-
DateWidget: DateWidget,
|
|
3307
|
-
DateTimeWidget: DateTimeWidget,
|
|
3308
|
-
AltDateWidget: AltDateWidget,
|
|
3309
|
-
AltDateTimeWidget: AltDateTimeWidget,
|
|
3310
|
-
EmailWidget: EmailWidget,
|
|
3311
|
-
URLWidget: URLWidget,
|
|
3312
3485
|
TextareaWidget: TextareaWidget,
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
CheckboxWidget: CheckboxWidget,
|
|
3317
|
-
CheckboxesWidget: CheckboxesWidget
|
|
3486
|
+
TimeWidget: TimeWidget,
|
|
3487
|
+
UpDownWidget: UpDownWidget,
|
|
3488
|
+
URLWidget: URLWidget
|
|
3318
3489
|
};
|
|
3319
3490
|
}
|
|
3320
3491
|
|
|
@@ -3352,7 +3523,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3352
3523
|
_this.formElement = void 0;
|
|
3353
3524
|
_this.getUsedFormData = function (formData, fields) {
|
|
3354
3525
|
// For the case of a single input form
|
|
3355
|
-
if (fields.length === 0 && typeof formData !==
|
|
3526
|
+
if (fields.length === 0 && typeof formData !== 'object') {
|
|
3356
3527
|
return formData;
|
|
3357
3528
|
}
|
|
3358
3529
|
// _pick has incorrect type definition, it works with string[][], because lodash/hasIn supports it
|
|
@@ -3373,22 +3544,22 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3373
3544
|
paths = [[]];
|
|
3374
3545
|
}
|
|
3375
3546
|
Object.keys(_obj).forEach(function (key) {
|
|
3376
|
-
if (typeof _obj[key] ===
|
|
3547
|
+
if (typeof _obj[key] === 'object') {
|
|
3377
3548
|
var newPaths = paths.map(function (path) {
|
|
3378
3549
|
return [].concat(path, [key]);
|
|
3379
3550
|
});
|
|
3380
3551
|
// If an object is marked with additionalProperties, all its keys are valid
|
|
3381
|
-
if (_obj[key][RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !==
|
|
3552
|
+
if (_obj[key][RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !== '') {
|
|
3382
3553
|
acc.push(_obj[key][NAME_KEY]);
|
|
3383
3554
|
} else {
|
|
3384
3555
|
getAllPaths(_obj[key], acc, newPaths);
|
|
3385
3556
|
}
|
|
3386
|
-
} else if (key === NAME_KEY && _obj[key] !==
|
|
3557
|
+
} else if (key === NAME_KEY && _obj[key] !== '') {
|
|
3387
3558
|
paths.forEach(function (path) {
|
|
3388
3559
|
var formValue = get(formData, path);
|
|
3389
3560
|
// adds path to fieldNames if it points to a value
|
|
3390
3561
|
// or an empty object/array
|
|
3391
|
-
if (typeof formValue !==
|
|
3562
|
+
if (typeof formValue !== 'object' || isEmpty(formValue)) {
|
|
3392
3563
|
acc.push(path);
|
|
3393
3564
|
}
|
|
3394
3565
|
});
|
|
@@ -3421,7 +3592,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3421
3592
|
var newFormData = formData;
|
|
3422
3593
|
if (omitExtraData === true && liveOmit === true) {
|
|
3423
3594
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3424
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3595
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
3425
3596
|
var fieldNames = _this.getFieldNames(pathSchema, formData);
|
|
3426
3597
|
newFormData = _this.getUsedFormData(formData, fieldNames);
|
|
3427
3598
|
state = {
|
|
@@ -3447,7 +3618,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3447
3618
|
schemaValidationErrorSchema: schemaValidationErrorSchema
|
|
3448
3619
|
};
|
|
3449
3620
|
} else if (!noValidate && newErrorSchema) {
|
|
3450
|
-
var _errorSchema = extraErrors ? mergeObjects(newErrorSchema, extraErrors,
|
|
3621
|
+
var _errorSchema = extraErrors ? mergeObjects(newErrorSchema, extraErrors, 'preventDuplicates') : newErrorSchema;
|
|
3451
3622
|
state = {
|
|
3452
3623
|
formData: newFormData,
|
|
3453
3624
|
errorSchema: _errorSchema,
|
|
@@ -3458,6 +3629,21 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3458
3629
|
return onChange && onChange(_extends({}, _this.state, state), id);
|
|
3459
3630
|
});
|
|
3460
3631
|
};
|
|
3632
|
+
_this.reset = function () {
|
|
3633
|
+
var onChange = _this.props.onChange;
|
|
3634
|
+
var newState = _this.getStateFromProps(_this.props, undefined);
|
|
3635
|
+
var newFormData = newState.formData;
|
|
3636
|
+
var state = {
|
|
3637
|
+
formData: newFormData,
|
|
3638
|
+
errorSchema: {},
|
|
3639
|
+
errors: [],
|
|
3640
|
+
schemaValidationErrors: [],
|
|
3641
|
+
schemaValidationErrorSchema: {}
|
|
3642
|
+
};
|
|
3643
|
+
_this.setState(state, function () {
|
|
3644
|
+
return onChange && onChange(_extends({}, _this.state, state));
|
|
3645
|
+
});
|
|
3646
|
+
};
|
|
3461
3647
|
_this.onBlur = function (id, data) {
|
|
3462
3648
|
var onBlur = _this.props.onBlur;
|
|
3463
3649
|
if (onBlur) {
|
|
@@ -3487,7 +3673,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3487
3673
|
schemaUtils = _this$state2.schemaUtils;
|
|
3488
3674
|
if (omitExtraData === true) {
|
|
3489
3675
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, newFormData);
|
|
3490
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3676
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', newFormData);
|
|
3491
3677
|
var fieldNames = _this.getFieldNames(pathSchema, newFormData);
|
|
3492
3678
|
newFormData = _this.getUsedFormData(newFormData, fieldNames);
|
|
3493
3679
|
}
|
|
@@ -3506,20 +3692,20 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3506
3692
|
if (onSubmit) {
|
|
3507
3693
|
onSubmit(_extends({}, _this.state, {
|
|
3508
3694
|
formData: newFormData,
|
|
3509
|
-
status:
|
|
3695
|
+
status: 'submitted'
|
|
3510
3696
|
}), event);
|
|
3511
3697
|
}
|
|
3512
3698
|
});
|
|
3513
3699
|
}
|
|
3514
3700
|
};
|
|
3515
3701
|
if (!props.validator) {
|
|
3516
|
-
throw new Error(
|
|
3702
|
+
throw new Error('A validator is required for Form functionality to work');
|
|
3517
3703
|
}
|
|
3518
3704
|
_this.state = _this.getStateFromProps(props, props.formData);
|
|
3519
3705
|
if (_this.props.onChange && !deepEquals(_this.state.formData, _this.props.formData)) {
|
|
3520
3706
|
_this.props.onChange(_this.state);
|
|
3521
3707
|
}
|
|
3522
|
-
_this.formElement = /*#__PURE__*/
|
|
3708
|
+
_this.formElement = /*#__PURE__*/createRef();
|
|
3523
3709
|
return _this;
|
|
3524
3710
|
}
|
|
3525
3711
|
/** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
|
|
@@ -3546,10 +3732,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3546
3732
|
*/;
|
|
3547
3733
|
_proto.getStateFromProps = function getStateFromProps(props, inputFormData) {
|
|
3548
3734
|
var state = this.state || {};
|
|
3549
|
-
var schema =
|
|
3550
|
-
var uiSchema = (
|
|
3551
|
-
var edit = typeof inputFormData !==
|
|
3552
|
-
var liveValidate =
|
|
3735
|
+
var schema = 'schema' in props ? props.schema : this.props.schema;
|
|
3736
|
+
var uiSchema = ('uiSchema' in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
3737
|
+
var edit = typeof inputFormData !== 'undefined';
|
|
3738
|
+
var liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
3553
3739
|
var mustValidate = edit && !props.noValidate && liveValidate;
|
|
3554
3740
|
var rootSchema = schema;
|
|
3555
3741
|
var schemaUtils = state.schemaUtils;
|
|
@@ -3598,7 +3784,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3598
3784
|
errorSchema = merged.errorSchema;
|
|
3599
3785
|
errors = merged.errors;
|
|
3600
3786
|
}
|
|
3601
|
-
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema[
|
|
3787
|
+
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema['ui:rootFieldId'], formData, props.idPrefix, props.idSeparator);
|
|
3602
3788
|
var nextState = {
|
|
3603
3789
|
schemaUtils: schemaUtils,
|
|
3604
3790
|
schema: schema,
|
|
@@ -3650,9 +3836,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3650
3836
|
uiSchema = _this$state3.uiSchema;
|
|
3651
3837
|
var formContext = this.props.formContext;
|
|
3652
3838
|
var options = getUiOptions(uiSchema);
|
|
3653
|
-
var ErrorListTemplate = getTemplate(
|
|
3839
|
+
var ErrorListTemplate = getTemplate('ErrorListTemplate', registry, options);
|
|
3654
3840
|
if (errors && errors.length) {
|
|
3655
|
-
return
|
|
3841
|
+
return jsx(ErrorListTemplate, {
|
|
3656
3842
|
errors: errors,
|
|
3657
3843
|
errorSchema: errorSchema || {},
|
|
3658
3844
|
schema: schema,
|
|
@@ -3671,7 +3857,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3671
3857
|
/** Returns the registry for the form */
|
|
3672
3858
|
_proto.getRegistry = function getRegistry() {
|
|
3673
3859
|
var _this$props$templates;
|
|
3674
|
-
var
|
|
3860
|
+
var _this$props4 = this.props,
|
|
3861
|
+
customTranslateString = _this$props4.translateString,
|
|
3862
|
+
_this$props4$uiSchema = _this$props4.uiSchema,
|
|
3863
|
+
uiSchema = _this$props4$uiSchema === void 0 ? {} : _this$props4$uiSchema;
|
|
3675
3864
|
var schemaUtils = this.state.schemaUtils;
|
|
3676
3865
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3677
3866
|
fields = _getDefaultRegistry.fields,
|
|
@@ -3688,13 +3877,14 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3688
3877
|
rootSchema: this.props.schema,
|
|
3689
3878
|
formContext: this.props.formContext || formContext,
|
|
3690
3879
|
schemaUtils: schemaUtils,
|
|
3691
|
-
translateString: customTranslateString || translateString
|
|
3880
|
+
translateString: customTranslateString || translateString,
|
|
3881
|
+
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY]
|
|
3692
3882
|
};
|
|
3693
3883
|
}
|
|
3694
3884
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
3695
3885
|
_proto.submit = function submit() {
|
|
3696
3886
|
if (this.formElement.current) {
|
|
3697
|
-
this.formElement.current.dispatchEvent(new CustomEvent(
|
|
3887
|
+
this.formElement.current.dispatchEvent(new CustomEvent('submit', {
|
|
3698
3888
|
cancelable: true
|
|
3699
3889
|
}));
|
|
3700
3890
|
this.formElement.current.requestSubmit();
|
|
@@ -3707,14 +3897,14 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3707
3897
|
* @param error - The error on which to focus
|
|
3708
3898
|
*/;
|
|
3709
3899
|
_proto.focusOnError = function focusOnError(error) {
|
|
3710
|
-
var _this$
|
|
3711
|
-
_this$
|
|
3712
|
-
idPrefix = _this$
|
|
3713
|
-
_this$
|
|
3714
|
-
idSeparator = _this$
|
|
3900
|
+
var _this$props5 = this.props,
|
|
3901
|
+
_this$props5$idPrefix = _this$props5.idPrefix,
|
|
3902
|
+
idPrefix = _this$props5$idPrefix === void 0 ? 'root' : _this$props5$idPrefix,
|
|
3903
|
+
_this$props5$idSepara = _this$props5.idSeparator,
|
|
3904
|
+
idSeparator = _this$props5$idSepara === void 0 ? '_' : _this$props5$idSepara;
|
|
3715
3905
|
var property = error.property;
|
|
3716
3906
|
var path = _toPath(property);
|
|
3717
|
-
if (path[0] ===
|
|
3907
|
+
if (path[0] === '') {
|
|
3718
3908
|
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3719
3909
|
path[0] = idPrefix;
|
|
3720
3910
|
} else {
|
|
@@ -3737,10 +3927,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3737
3927
|
* @returns - True if the form is valid, false otherwise.
|
|
3738
3928
|
*/;
|
|
3739
3929
|
_proto.validateForm = function validateForm() {
|
|
3740
|
-
var _this$
|
|
3741
|
-
extraErrors = _this$
|
|
3742
|
-
focusOnFirstError = _this$
|
|
3743
|
-
onError = _this$
|
|
3930
|
+
var _this$props6 = this.props,
|
|
3931
|
+
extraErrors = _this$props6.extraErrors,
|
|
3932
|
+
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
3933
|
+
onError = _this$props6.onError;
|
|
3744
3934
|
var formData = this.state.formData;
|
|
3745
3935
|
var schemaUtils = this.state.schemaUtils;
|
|
3746
3936
|
var schemaValidation = this.validate(formData);
|
|
@@ -3766,7 +3956,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3766
3956
|
if (onError) {
|
|
3767
3957
|
onError(errors);
|
|
3768
3958
|
} else {
|
|
3769
|
-
console.error(
|
|
3959
|
+
console.error('Form validation failed', errors);
|
|
3770
3960
|
}
|
|
3771
3961
|
});
|
|
3772
3962
|
return false;
|
|
@@ -3777,31 +3967,31 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3777
3967
|
* needed along with the submit button or any children of the form.
|
|
3778
3968
|
*/;
|
|
3779
3969
|
_proto.render = function render() {
|
|
3780
|
-
var _this$
|
|
3781
|
-
children = _this$
|
|
3782
|
-
id = _this$
|
|
3783
|
-
idPrefix = _this$
|
|
3784
|
-
idSeparator = _this$
|
|
3785
|
-
_this$
|
|
3786
|
-
className = _this$
|
|
3787
|
-
tagName = _this$
|
|
3788
|
-
name = _this$
|
|
3789
|
-
method = _this$
|
|
3790
|
-
target = _this$
|
|
3791
|
-
action = _this$
|
|
3792
|
-
autoComplete = _this$
|
|
3793
|
-
enctype = _this$
|
|
3794
|
-
acceptcharset = _this$
|
|
3795
|
-
_this$
|
|
3796
|
-
noHtml5Validate = _this$
|
|
3797
|
-
_this$
|
|
3798
|
-
disabled = _this$
|
|
3799
|
-
_this$
|
|
3800
|
-
readonly = _this$
|
|
3801
|
-
formContext = _this$
|
|
3802
|
-
_this$
|
|
3803
|
-
showErrorList = _this$
|
|
3804
|
-
_internalFormWrapper = _this$
|
|
3970
|
+
var _this$props7 = this.props,
|
|
3971
|
+
children = _this$props7.children,
|
|
3972
|
+
id = _this$props7.id,
|
|
3973
|
+
idPrefix = _this$props7.idPrefix,
|
|
3974
|
+
idSeparator = _this$props7.idSeparator,
|
|
3975
|
+
_this$props7$classNam = _this$props7.className,
|
|
3976
|
+
className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
|
|
3977
|
+
tagName = _this$props7.tagName,
|
|
3978
|
+
name = _this$props7.name,
|
|
3979
|
+
method = _this$props7.method,
|
|
3980
|
+
target = _this$props7.target,
|
|
3981
|
+
action = _this$props7.action,
|
|
3982
|
+
autoComplete = _this$props7.autoComplete,
|
|
3983
|
+
enctype = _this$props7.enctype,
|
|
3984
|
+
acceptcharset = _this$props7.acceptcharset,
|
|
3985
|
+
_this$props7$noHtml5V = _this$props7.noHtml5Validate,
|
|
3986
|
+
noHtml5Validate = _this$props7$noHtml5V === void 0 ? false : _this$props7$noHtml5V,
|
|
3987
|
+
_this$props7$disabled = _this$props7.disabled,
|
|
3988
|
+
disabled = _this$props7$disabled === void 0 ? false : _this$props7$disabled,
|
|
3989
|
+
_this$props7$readonly = _this$props7.readonly,
|
|
3990
|
+
readonly = _this$props7$readonly === void 0 ? false : _this$props7$readonly,
|
|
3991
|
+
formContext = _this$props7.formContext,
|
|
3992
|
+
_this$props7$showErro = _this$props7.showErrorList,
|
|
3993
|
+
showErrorList = _this$props7$showErro === void 0 ? 'top' : _this$props7$showErro,
|
|
3994
|
+
_internalFormWrapper = _this$props7._internalFormWrapper;
|
|
3805
3995
|
var _this$state4 = this.state,
|
|
3806
3996
|
schema = _this$state4.schema,
|
|
3807
3997
|
uiSchema = _this$state4.uiSchema,
|
|
@@ -3815,9 +4005,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3815
4005
|
// PropTypes.elementType to use for the inner tag, so we'll need to pass `tagName` along if it is provided.
|
|
3816
4006
|
// NOTE, the `as` prop is native to `semantic-ui` and is emulated in the `material-ui` theme
|
|
3817
4007
|
var as = _internalFormWrapper ? tagName : undefined;
|
|
3818
|
-
var FormTag = _internalFormWrapper || tagName ||
|
|
3819
|
-
return
|
|
3820
|
-
className: className ? className :
|
|
4008
|
+
var FormTag = _internalFormWrapper || tagName || 'form';
|
|
4009
|
+
return jsxs(FormTag, {
|
|
4010
|
+
className: className ? className : 'rjsf',
|
|
3821
4011
|
id: id,
|
|
3822
4012
|
name: name,
|
|
3823
4013
|
method: method,
|
|
@@ -3829,27 +4019,28 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3829
4019
|
noValidate: noHtml5Validate,
|
|
3830
4020
|
onSubmit: this.onSubmit,
|
|
3831
4021
|
as: as,
|
|
3832
|
-
ref: this.formElement
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
4022
|
+
ref: this.formElement,
|
|
4023
|
+
children: [showErrorList === 'top' && this.renderErrors(registry), jsx(_SchemaField, {
|
|
4024
|
+
name: '',
|
|
4025
|
+
schema: schema,
|
|
4026
|
+
uiSchema: uiSchema,
|
|
4027
|
+
errorSchema: errorSchema,
|
|
4028
|
+
idSchema: idSchema,
|
|
4029
|
+
idPrefix: idPrefix,
|
|
4030
|
+
idSeparator: idSeparator,
|
|
4031
|
+
formContext: formContext,
|
|
4032
|
+
formData: formData,
|
|
4033
|
+
onChange: this.onChange,
|
|
4034
|
+
onBlur: this.onBlur,
|
|
4035
|
+
onFocus: this.onFocus,
|
|
4036
|
+
registry: registry,
|
|
4037
|
+
disabled: disabled,
|
|
4038
|
+
readonly: readonly
|
|
4039
|
+
}), children ? children : jsx(SubmitButton, {
|
|
4040
|
+
uiSchema: uiSchema,
|
|
4041
|
+
registry: registry
|
|
4042
|
+
}), showErrorList === 'bottom' && this.renderErrors(registry)]
|
|
4043
|
+
});
|
|
3853
4044
|
};
|
|
3854
4045
|
return Form;
|
|
3855
4046
|
}(Component);
|
|
@@ -3868,7 +4059,7 @@ function withTheme(themeProps) {
|
|
|
3868
4059
|
templates = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.templates, templates, {
|
|
3869
4060
|
ButtonTemplates: _extends({}, themeProps === null || themeProps === void 0 ? void 0 : (_themeProps$templates = themeProps.templates) === null || _themeProps$templates === void 0 ? void 0 : _themeProps$templates.ButtonTemplates, (_templates = templates) === null || _templates === void 0 ? void 0 : _templates.ButtonTemplates)
|
|
3870
4061
|
});
|
|
3871
|
-
return
|
|
4062
|
+
return jsx(Form, _extends({}, themeProps, directProps, {
|
|
3872
4063
|
fields: fields,
|
|
3873
4064
|
widgets: widgets,
|
|
3874
4065
|
templates: templates,
|