@rjsf/core 5.2.0 → 5.2.1
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 +831 -735
- 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 +798 -701
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +833 -738
- 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 +17 -17
- package/package.json +5 -5
package/dist/core.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Component, useState, useCallback, useEffect, useReducer, useMemo, createRef, forwardRef } from 'react';
|
|
2
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, 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';
|
|
@@ -231,7 +232,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
231
232
|
var newFormData = arrayData.map(function (item, i) {
|
|
232
233
|
// We need to treat undefined items as nulls to have validation.
|
|
233
234
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
234
|
-
var jsonValue = typeof value ===
|
|
235
|
+
var jsonValue = typeof value === 'undefined' ? null : value;
|
|
235
236
|
return index === i ? jsonValue : item;
|
|
236
237
|
});
|
|
237
238
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends2 = {}, _extends2[index] = newErrorSchema, _extends2)), id);
|
|
@@ -291,10 +292,10 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
291
292
|
if (Array.isArray(itemSchema.type)) {
|
|
292
293
|
// While we don't yet support composite/nullable jsonschema types, it's
|
|
293
294
|
// future-proof to check for requirement against these.
|
|
294
|
-
return !itemSchema.type.includes(
|
|
295
|
+
return !itemSchema.type.includes('null');
|
|
295
296
|
}
|
|
296
297
|
// All non-null array item types are inherently required by design
|
|
297
|
-
return itemSchema.type !==
|
|
298
|
+
return itemSchema.type !== 'null';
|
|
298
299
|
}
|
|
299
300
|
/** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
|
|
300
301
|
* then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
|
|
@@ -371,8 +372,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
371
372
|
translateString = registry.translateString;
|
|
372
373
|
if (!(ITEMS_KEY in schema)) {
|
|
373
374
|
var uiOptions = getUiOptions(uiSchema);
|
|
374
|
-
var UnsupportedFieldTemplate = getTemplate(
|
|
375
|
-
return
|
|
375
|
+
var UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
376
|
+
return jsx(UnsupportedFieldTemplate, {
|
|
376
377
|
schema: schema,
|
|
377
378
|
idSchema: idSchema,
|
|
378
379
|
reason: translateString(TranslatableString.MissingItems),
|
|
@@ -418,7 +419,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
418
419
|
onFocus = _this$props8.onFocus,
|
|
419
420
|
idPrefix = _this$props8.idPrefix,
|
|
420
421
|
_this$props8$idSepara = _this$props8.idSeparator,
|
|
421
|
-
idSeparator = _this$props8$idSepara === void 0 ?
|
|
422
|
+
idSeparator = _this$props8$idSepara === void 0 ? '_' : _this$props8$idSepara,
|
|
422
423
|
rawErrors = _this$props8.rawErrors;
|
|
423
424
|
var keyedFormData = this.state.keyedFormData;
|
|
424
425
|
var title = schema.title === undefined ? name : schema.title;
|
|
@@ -473,8 +474,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
473
474
|
rawErrors: rawErrors,
|
|
474
475
|
registry: registry
|
|
475
476
|
};
|
|
476
|
-
var Template = getTemplate(
|
|
477
|
-
return
|
|
477
|
+
var Template = getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
478
|
+
return jsx(Template, _extends({}, arrayProps));
|
|
478
479
|
}
|
|
479
480
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
480
481
|
*/;
|
|
@@ -507,8 +508,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
507
508
|
widget = _getUiOptions2.widget,
|
|
508
509
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
509
510
|
var Widget = getWidget(schema, widget, widgets);
|
|
510
|
-
return
|
|
511
|
+
return jsx(Widget, {
|
|
511
512
|
id: idSchema.$id,
|
|
513
|
+
name: name,
|
|
512
514
|
multiple: true,
|
|
513
515
|
onChange: this.onSelectChange,
|
|
514
516
|
onBlur: onBlur,
|
|
@@ -560,11 +562,12 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
560
562
|
var enumOptions = optionsList(itemsSchema);
|
|
561
563
|
var _getUiOptions3 = getUiOptions(uiSchema),
|
|
562
564
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
563
|
-
widget = _getUiOptions3$widget === void 0 ?
|
|
565
|
+
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
564
566
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
565
567
|
var Widget = getWidget(schema, widget, widgets);
|
|
566
|
-
return
|
|
568
|
+
return jsx(Widget, {
|
|
567
569
|
id: idSchema.$id,
|
|
570
|
+
name: name,
|
|
568
571
|
multiple: true,
|
|
569
572
|
onChange: this.onSelectChange,
|
|
570
573
|
onBlur: onBlur,
|
|
@@ -613,12 +616,13 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
613
616
|
formContext = registry.formContext;
|
|
614
617
|
var _getUiOptions4 = getUiOptions(uiSchema),
|
|
615
618
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
616
|
-
widget = _getUiOptions4$widget === void 0 ?
|
|
619
|
+
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
617
620
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
618
621
|
var Widget = getWidget(schema, widget, widgets);
|
|
619
|
-
return
|
|
622
|
+
return jsx(Widget, {
|
|
620
623
|
options: options,
|
|
621
624
|
id: idSchema.$id,
|
|
625
|
+
name: name,
|
|
622
626
|
multiple: true,
|
|
623
627
|
onChange: this.onSelectChange,
|
|
624
628
|
onBlur: onBlur,
|
|
@@ -634,7 +638,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
634
638
|
formContext: formContext,
|
|
635
639
|
autofocus: autofocus,
|
|
636
640
|
rawErrors: rawErrors,
|
|
637
|
-
label:
|
|
641
|
+
label: ''
|
|
638
642
|
});
|
|
639
643
|
}
|
|
640
644
|
/** Renders an array that has a maximum limit of items
|
|
@@ -650,7 +654,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
650
654
|
errorSchema = _this$props12.errorSchema,
|
|
651
655
|
idPrefix = _this$props12.idPrefix,
|
|
652
656
|
_this$props12$idSepar = _this$props12.idSeparator,
|
|
653
|
-
idSeparator = _this$props12$idSepar === void 0 ?
|
|
657
|
+
idSeparator = _this$props12$idSepar === void 0 ? '_' : _this$props12$idSepar,
|
|
654
658
|
idSchema = _this$props12.idSchema,
|
|
655
659
|
name = _this$props12.name,
|
|
656
660
|
_this$props12$disable = _this$props12.disabled,
|
|
@@ -686,7 +690,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
686
690
|
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
687
691
|
var arrayProps = {
|
|
688
692
|
canAdd: canAdd,
|
|
689
|
-
className:
|
|
693
|
+
className: 'field field-array field-array-fixed-items',
|
|
690
694
|
disabled: disabled,
|
|
691
695
|
idSchema: idSchema,
|
|
692
696
|
formData: formData,
|
|
@@ -731,8 +735,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
731
735
|
formContext: formContext,
|
|
732
736
|
rawErrors: rawErrors
|
|
733
737
|
};
|
|
734
|
-
var Template = getTemplate(
|
|
735
|
-
return
|
|
738
|
+
var Template = getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
739
|
+
return jsx(Template, _extends({}, arrayProps));
|
|
736
740
|
}
|
|
737
741
|
/** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
|
|
738
742
|
* back to the `ArrayFieldItemTemplate`.
|
|
@@ -788,7 +792,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
788
792
|
return has[key];
|
|
789
793
|
});
|
|
790
794
|
return {
|
|
791
|
-
children:
|
|
795
|
+
children: jsx(ItemSchemaField, {
|
|
792
796
|
name: name,
|
|
793
797
|
index: index,
|
|
794
798
|
schema: itemSchema,
|
|
@@ -810,7 +814,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
810
814
|
autofocus: autofocus,
|
|
811
815
|
rawErrors: rawErrors
|
|
812
816
|
}),
|
|
813
|
-
className:
|
|
817
|
+
className: 'array-item',
|
|
814
818
|
disabled: disabled,
|
|
815
819
|
canAdd: canAdd,
|
|
816
820
|
hasToolbar: has.toolbar,
|
|
@@ -836,7 +840,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
836
840
|
schema = _this$props14.schema,
|
|
837
841
|
registry = _this$props14.registry;
|
|
838
842
|
var translateString = registry.translateString;
|
|
839
|
-
return get(schema, [ITEMS_KEY,
|
|
843
|
+
return get(schema, [ITEMS_KEY, 'title'], get(schema, [ITEMS_KEY, 'description'], translateString(TranslatableString.ArrayItemTitle)));
|
|
840
844
|
}
|
|
841
845
|
}]);
|
|
842
846
|
return ArrayField;
|
|
@@ -869,7 +873,7 @@ function BooleanField(props) {
|
|
|
869
873
|
translateString = registry.translateString;
|
|
870
874
|
var _getUiOptions = getUiOptions(uiSchema),
|
|
871
875
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
872
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
876
|
+
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
873
877
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
874
878
|
var Widget = getWidget(schema, widget, widgets);
|
|
875
879
|
var yes = translateString(TranslatableString.YesLabel);
|
|
@@ -894,7 +898,7 @@ function BooleanField(props) {
|
|
|
894
898
|
var schemaWithEnumNames = schema;
|
|
895
899
|
var enums = (_schema$enum = schema["enum"]) != null ? _schema$enum : [true, false];
|
|
896
900
|
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every(function (v) {
|
|
897
|
-
return typeof v ===
|
|
901
|
+
return typeof v === 'boolean';
|
|
898
902
|
})) {
|
|
899
903
|
enumOptions = [{
|
|
900
904
|
value: enums[0],
|
|
@@ -911,13 +915,14 @@ function BooleanField(props) {
|
|
|
911
915
|
});
|
|
912
916
|
}
|
|
913
917
|
}
|
|
914
|
-
return
|
|
918
|
+
return jsx(Widget, {
|
|
915
919
|
options: _extends({}, options, {
|
|
916
920
|
enumOptions: enumOptions
|
|
917
921
|
}),
|
|
918
922
|
schema: schema,
|
|
919
923
|
uiSchema: uiSchema,
|
|
920
924
|
id: idSchema.$id,
|
|
925
|
+
name: name,
|
|
921
926
|
onChange: onChange,
|
|
922
927
|
onFocus: onFocus,
|
|
923
928
|
onBlur: onBlur,
|
|
@@ -967,7 +972,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
967
972
|
if (newFormData && newOption) {
|
|
968
973
|
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
969
974
|
// so that only the root objects themselves are created without adding undefined children properties
|
|
970
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData,
|
|
975
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
971
976
|
}
|
|
972
977
|
onChange(newFormData, undefined, _this.getFieldId());
|
|
973
978
|
_this.setState({
|
|
@@ -1054,12 +1059,13 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1054
1059
|
var _this$props4 = this.props,
|
|
1055
1060
|
idSchema = _this$props4.idSchema,
|
|
1056
1061
|
schema = _this$props4.schema;
|
|
1057
|
-
return "" + idSchema.$id + (schema.oneOf ?
|
|
1062
|
+
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1058
1063
|
}
|
|
1059
1064
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1060
1065
|
*/;
|
|
1061
1066
|
_proto.render = function render() {
|
|
1062
1067
|
var _this$props5 = this.props,
|
|
1068
|
+
name = _this$props5.name,
|
|
1063
1069
|
baseType = _this$props5.baseType,
|
|
1064
1070
|
_this$props5$disabled = _this$props5.disabled,
|
|
1065
1071
|
disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
|
|
@@ -1080,7 +1086,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1080
1086
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1081
1087
|
var _getUiOptions = getUiOptions(uiSchema),
|
|
1082
1088
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1083
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
1089
|
+
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1084
1090
|
placeholder = _getUiOptions.placeholder,
|
|
1085
1091
|
autofocus = _getUiOptions.autofocus,
|
|
1086
1092
|
autocomplete = _getUiOptions.autocomplete,
|
|
@@ -1088,7 +1094,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1088
1094
|
title = _getUiOptions$title === void 0 ? schema.title : _getUiOptions$title,
|
|
1089
1095
|
uiOptions = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$7);
|
|
1090
1096
|
var Widget = getWidget({
|
|
1091
|
-
type:
|
|
1097
|
+
type: 'number'
|
|
1092
1098
|
}, widget, widgets);
|
|
1093
1099
|
var rawErrors = get(errorSchema, ERRORS_KEY, []);
|
|
1094
1100
|
var fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
|
|
@@ -1109,36 +1115,39 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1109
1115
|
value: index
|
|
1110
1116
|
};
|
|
1111
1117
|
});
|
|
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
|
-
|
|
1118
|
+
return jsxs("div", {
|
|
1119
|
+
className: 'panel panel-default panel-body',
|
|
1120
|
+
children: [jsx("div", {
|
|
1121
|
+
className: 'form-group',
|
|
1122
|
+
children: jsx(Widget, {
|
|
1123
|
+
id: this.getFieldId(),
|
|
1124
|
+
name: "" + name + (schema.oneOf ? '__oneof_select' : '__anyof_select'),
|
|
1125
|
+
schema: {
|
|
1126
|
+
type: 'number',
|
|
1127
|
+
"default": 0
|
|
1128
|
+
},
|
|
1129
|
+
onChange: this.onOptionChange,
|
|
1130
|
+
onBlur: onBlur,
|
|
1131
|
+
onFocus: onFocus,
|
|
1132
|
+
disabled: disabled || isEmpty(enumOptions),
|
|
1133
|
+
multiple: false,
|
|
1134
|
+
rawErrors: rawErrors,
|
|
1135
|
+
errorSchema: fieldErrorSchema,
|
|
1136
|
+
value: selectedOption >= 0 ? selectedOption : undefined,
|
|
1137
|
+
options: _extends({
|
|
1138
|
+
enumOptions: enumOptions
|
|
1139
|
+
}, uiOptions),
|
|
1140
|
+
registry: registry,
|
|
1141
|
+
formContext: formContext,
|
|
1142
|
+
placeholder: placeholder,
|
|
1143
|
+
autocomplete: autocomplete,
|
|
1144
|
+
autofocus: autofocus,
|
|
1145
|
+
label: ''
|
|
1146
|
+
})
|
|
1147
|
+
}), option !== null && jsx(_SchemaField, _extends({}, this.props, {
|
|
1148
|
+
schema: optionSchema
|
|
1149
|
+
}))]
|
|
1150
|
+
});
|
|
1142
1151
|
};
|
|
1143
1152
|
return AnyOfField;
|
|
1144
1153
|
}(Component);
|
|
@@ -1189,27 +1198,27 @@ function NumberField(props) {
|
|
|
1189
1198
|
setLastValue(value);
|
|
1190
1199
|
// Normalize decimals that don't start with a zero character in advance so
|
|
1191
1200
|
// that the rest of the normalization logic is simpler
|
|
1192
|
-
if (("" + value).charAt(0) ===
|
|
1201
|
+
if (("" + value).charAt(0) === '.') {
|
|
1193
1202
|
value = "0" + value;
|
|
1194
1203
|
}
|
|
1195
1204
|
// Check that the value is a string (this can happen if the widget used is a
|
|
1196
1205
|
// <select>, due to an enum declaration etc) then, if the value ends in a
|
|
1197
1206
|
// trailing decimal point or multiple zeroes, strip the trailing values
|
|
1198
|
-
var processed = typeof value ===
|
|
1207
|
+
var processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix) ? asNumber(value.replace(trailingCharMatcher, '')) : asNumber(value);
|
|
1199
1208
|
onChange(processed);
|
|
1200
1209
|
}, [onChange]);
|
|
1201
|
-
if (typeof lastValue ===
|
|
1210
|
+
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
1202
1211
|
// Construct a regular expression that checks for a string that consists
|
|
1203
1212
|
// of the formData value suffixed with zero or one '.' characters and zero
|
|
1204
1213
|
// or more '0' characters
|
|
1205
|
-
var re = new RegExp(("" + value).replace(
|
|
1214
|
+
var re = new RegExp(("" + value).replace('.', '\\.') + '\\.?0*$');
|
|
1206
1215
|
// If the cached "lastValue" is a match, use that instead of the formData
|
|
1207
1216
|
// value to prevent the input value from changing in the UI
|
|
1208
1217
|
if (lastValue.match(re)) {
|
|
1209
1218
|
value = lastValue;
|
|
1210
1219
|
}
|
|
1211
1220
|
}
|
|
1212
|
-
return
|
|
1221
|
+
return jsx(StringField, _extends({}, props, {
|
|
1213
1222
|
formData: value,
|
|
1214
1223
|
onChange: handleChange
|
|
1215
1224
|
}));
|
|
@@ -1250,7 +1259,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1250
1259
|
// fields which are "mandated" by the schema, these fields can
|
|
1251
1260
|
// be set to undefined by clicking a "delete field" button, so
|
|
1252
1261
|
// set empty values to the empty string.
|
|
1253
|
-
value =
|
|
1262
|
+
value = '';
|
|
1254
1263
|
}
|
|
1255
1264
|
var newFormData = _extends({}, formData, (_extends2 = {}, _extends2[name] = value, _extends2));
|
|
1256
1265
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends3 = {}, _extends3[name] = newErrorSchema, _extends3)), id);
|
|
@@ -1271,7 +1280,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1271
1280
|
var uiSchema = _this.props.uiSchema;
|
|
1272
1281
|
var _getUiOptions = getUiOptions(uiSchema),
|
|
1273
1282
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1274
|
-
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ?
|
|
1283
|
+
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1275
1284
|
var index = 0;
|
|
1276
1285
|
var newKey = preferredKey;
|
|
1277
1286
|
while (has(formData, newKey)) {
|
|
@@ -1326,10 +1335,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1326
1335
|
type = apSchema.type;
|
|
1327
1336
|
}
|
|
1328
1337
|
if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
|
|
1329
|
-
type =
|
|
1338
|
+
type = 'object';
|
|
1330
1339
|
}
|
|
1331
1340
|
}
|
|
1332
|
-
var newKey = _this.getAvailableKey(
|
|
1341
|
+
var newKey = _this.getAvailableKey('newKey', newFormData);
|
|
1333
1342
|
// Cast this to make the `set` work properly
|
|
1334
1343
|
set(newFormData, newKey, _this.getDefaultValue(type));
|
|
1335
1344
|
onChange(newFormData);
|
|
@@ -1362,17 +1371,17 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1362
1371
|
_proto.getDefaultValue = function getDefaultValue(type) {
|
|
1363
1372
|
var translateString = this.props.registry.translateString;
|
|
1364
1373
|
switch (type) {
|
|
1365
|
-
case
|
|
1374
|
+
case 'array':
|
|
1366
1375
|
return [];
|
|
1367
|
-
case
|
|
1376
|
+
case 'boolean':
|
|
1368
1377
|
return false;
|
|
1369
|
-
case
|
|
1378
|
+
case 'null':
|
|
1370
1379
|
return null;
|
|
1371
|
-
case
|
|
1380
|
+
case 'number':
|
|
1372
1381
|
return 0;
|
|
1373
|
-
case
|
|
1382
|
+
case 'object':
|
|
1374
1383
|
return {};
|
|
1375
|
-
case
|
|
1384
|
+
case 'string':
|
|
1376
1385
|
default:
|
|
1377
1386
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1378
1387
|
return translateString(TranslatableString.NewStringDefault);
|
|
@@ -1422,25 +1431,31 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1422
1431
|
var properties = Object.keys(schemaProperties);
|
|
1423
1432
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
1424
1433
|
} catch (err) {
|
|
1425
|
-
return
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1434
|
+
return jsxs("div", {
|
|
1435
|
+
children: [jsxs("p", {
|
|
1436
|
+
className: 'config-error',
|
|
1437
|
+
style: {
|
|
1438
|
+
color: 'red'
|
|
1439
|
+
},
|
|
1440
|
+
children: ["Invalid ", name || 'root', " object field configuration:", jsx("em", {
|
|
1441
|
+
children: err.message
|
|
1442
|
+
}), "."]
|
|
1443
|
+
}), jsx("pre", {
|
|
1444
|
+
children: JSON.stringify(schema)
|
|
1445
|
+
})]
|
|
1446
|
+
});
|
|
1431
1447
|
}
|
|
1432
|
-
var Template = getTemplate(
|
|
1448
|
+
var Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1433
1449
|
var templateProps = {
|
|
1434
1450
|
title: uiOptions.title || title,
|
|
1435
1451
|
description: description,
|
|
1436
1452
|
properties: orderedProperties.map(function (name) {
|
|
1437
1453
|
var addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
|
|
1438
1454
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
1439
|
-
var hidden = getUiOptions(fieldUiSchema).widget ===
|
|
1455
|
+
var hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
1440
1456
|
var fieldIdSchema = get(idSchema, [name], {});
|
|
1441
1457
|
return {
|
|
1442
|
-
content:
|
|
1443
|
-
key: name,
|
|
1458
|
+
content: jsx(SchemaField, {
|
|
1444
1459
|
name: name,
|
|
1445
1460
|
required: _this2.isRequired(name),
|
|
1446
1461
|
schema: get(schema, [PROPERTIES_KEY, name], {}),
|
|
@@ -1461,7 +1476,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1461
1476
|
readonly: readonly,
|
|
1462
1477
|
hideError: hideError,
|
|
1463
1478
|
onDropPropertyClick: _this2.onDropPropertyClick
|
|
1464
|
-
}),
|
|
1479
|
+
}, name),
|
|
1465
1480
|
name: name,
|
|
1466
1481
|
readonly: readonly,
|
|
1467
1482
|
disabled: disabled,
|
|
@@ -1479,7 +1494,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1479
1494
|
formContext: formContext,
|
|
1480
1495
|
registry: registry
|
|
1481
1496
|
};
|
|
1482
|
-
return
|
|
1497
|
+
return jsx(Template, _extends({}, templateProps, {
|
|
1483
1498
|
onAddClick: this.handleAddClick
|
|
1484
1499
|
}));
|
|
1485
1500
|
};
|
|
@@ -1489,13 +1504,13 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1489
1504
|
var _excluded$6 = ["__errors"];
|
|
1490
1505
|
/** The map of component type to FieldName */
|
|
1491
1506
|
var COMPONENT_TYPES = {
|
|
1492
|
-
array:
|
|
1493
|
-
"boolean":
|
|
1494
|
-
integer:
|
|
1495
|
-
number:
|
|
1496
|
-
object:
|
|
1497
|
-
string:
|
|
1498
|
-
"null":
|
|
1507
|
+
array: 'ArrayField',
|
|
1508
|
+
"boolean": 'BooleanField',
|
|
1509
|
+
integer: 'NumberField',
|
|
1510
|
+
number: 'NumberField',
|
|
1511
|
+
object: 'ObjectField',
|
|
1512
|
+
string: 'StringField',
|
|
1513
|
+
"null": 'NullField'
|
|
1499
1514
|
};
|
|
1500
1515
|
/** Computes and returns which `Field` implementation to return in order to render the field represented by the
|
|
1501
1516
|
* `schema`. The `uiOptions` are used to alter what potential `Field` implementation is actually returned. If no
|
|
@@ -1511,14 +1526,14 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1511
1526
|
var field = uiOptions.field;
|
|
1512
1527
|
var fields = registry.fields,
|
|
1513
1528
|
translateString = registry.translateString;
|
|
1514
|
-
if (typeof field ===
|
|
1529
|
+
if (typeof field === 'function') {
|
|
1515
1530
|
return field;
|
|
1516
1531
|
}
|
|
1517
|
-
if (typeof field ===
|
|
1532
|
+
if (typeof field === 'string' && field in fields) {
|
|
1518
1533
|
return fields[field];
|
|
1519
1534
|
}
|
|
1520
1535
|
var schemaType = getSchemaType(schema);
|
|
1521
|
-
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType ||
|
|
1536
|
+
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
|
|
1522
1537
|
var componentName = COMPONENT_TYPES[type];
|
|
1523
1538
|
// If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
|
|
1524
1539
|
// render a field and let the MultiSchemaField component handle the form display
|
|
@@ -1528,8 +1543,8 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1528
1543
|
};
|
|
1529
1544
|
}
|
|
1530
1545
|
return componentName in fields ? fields[componentName] : function () {
|
|
1531
|
-
var UnsupportedFieldTemplate = getTemplate(
|
|
1532
|
-
return
|
|
1546
|
+
var UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
1547
|
+
return jsx(UnsupportedFieldTemplate, {
|
|
1533
1548
|
schema: schema,
|
|
1534
1549
|
idSchema: idSchema,
|
|
1535
1550
|
reason: translateString(TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
@@ -1562,17 +1577,17 @@ function SchemaFieldRender(props) {
|
|
|
1562
1577
|
var formContext = registry.formContext,
|
|
1563
1578
|
schemaUtils = registry.schemaUtils;
|
|
1564
1579
|
var uiOptions = getUiOptions(uiSchema);
|
|
1565
|
-
var FieldTemplate = getTemplate(
|
|
1566
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
1567
|
-
var FieldHelpTemplate = getTemplate(
|
|
1568
|
-
var FieldErrorTemplate = getTemplate(
|
|
1580
|
+
var FieldTemplate = getTemplate('FieldTemplate', registry, uiOptions);
|
|
1581
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1582
|
+
var FieldHelpTemplate = getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
1583
|
+
var FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
1569
1584
|
var schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1570
1585
|
var fieldId = _idSchema[ID_KEY];
|
|
1571
1586
|
var idSchema = mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
1572
1587
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
1573
1588
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
1574
1589
|
*/
|
|
1575
|
-
var handleFieldComponentChange =
|
|
1590
|
+
var handleFieldComponentChange = useCallback(function (formData, newErrorSchema, id) {
|
|
1576
1591
|
var theId = id || fieldId;
|
|
1577
1592
|
return onChange(formData, newErrorSchema, theId);
|
|
1578
1593
|
}, [fieldId, onChange]);
|
|
@@ -1591,11 +1606,11 @@ function SchemaFieldRender(props) {
|
|
|
1591
1606
|
__errors = _ref.__errors,
|
|
1592
1607
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1593
1608
|
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1594
|
-
var fieldUiSchema = omit(uiSchema, [
|
|
1609
|
+
var fieldUiSchema = omit(uiSchema, ['ui:classNames', 'classNames', 'ui:style']);
|
|
1595
1610
|
if (UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1596
|
-
fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], [
|
|
1611
|
+
fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
1597
1612
|
}
|
|
1598
|
-
var field =
|
|
1613
|
+
var field = jsx(FieldComponent, _extends({}, props, {
|
|
1599
1614
|
onChange: handleFieldComponentChange,
|
|
1600
1615
|
idSchema: idSchema,
|
|
1601
1616
|
schema: schema,
|
|
@@ -1616,15 +1631,15 @@ function SchemaFieldRender(props) {
|
|
|
1616
1631
|
} else {
|
|
1617
1632
|
label = ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1618
1633
|
}
|
|
1619
|
-
var description = uiOptions.description || props.schema.description || schema.description ||
|
|
1634
|
+
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1620
1635
|
var help = uiOptions.help;
|
|
1621
|
-
var hidden = uiOptions.widget ===
|
|
1622
|
-
var classNames = [
|
|
1636
|
+
var hidden = uiOptions.widget === 'hidden';
|
|
1637
|
+
var classNames = ['form-group', 'field', "field-" + schema.type];
|
|
1623
1638
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1624
|
-
classNames.push(
|
|
1639
|
+
classNames.push('field-error has-error has-danger');
|
|
1625
1640
|
}
|
|
1626
1641
|
if (uiSchema !== null && uiSchema !== void 0 && uiSchema.classNames) {
|
|
1627
|
-
if (process.env.NODE_ENV !==
|
|
1642
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1628
1643
|
console.warn("'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead.");
|
|
1629
1644
|
}
|
|
1630
1645
|
classNames.push(uiSchema.classNames);
|
|
@@ -1632,7 +1647,7 @@ function SchemaFieldRender(props) {
|
|
|
1632
1647
|
if (uiOptions.classNames) {
|
|
1633
1648
|
classNames.push(uiOptions.classNames);
|
|
1634
1649
|
}
|
|
1635
|
-
var helpComponent =
|
|
1650
|
+
var helpComponent = jsx(FieldHelpTemplate, {
|
|
1636
1651
|
help: help,
|
|
1637
1652
|
idSchema: idSchema,
|
|
1638
1653
|
schema: schema,
|
|
@@ -1640,7 +1655,7 @@ function SchemaFieldRender(props) {
|
|
|
1640
1655
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
1641
1656
|
registry: registry
|
|
1642
1657
|
});
|
|
1643
|
-
var errorsComponent = hideError ? undefined :
|
|
1658
|
+
var errorsComponent = hideError ? undefined : jsx(FieldErrorTemplate, {
|
|
1644
1659
|
errors: __errors,
|
|
1645
1660
|
errorSchema: errorSchema,
|
|
1646
1661
|
idSchema: idSchema,
|
|
@@ -1649,7 +1664,7 @@ function SchemaFieldRender(props) {
|
|
|
1649
1664
|
registry: registry
|
|
1650
1665
|
});
|
|
1651
1666
|
var fieldProps = {
|
|
1652
|
-
description:
|
|
1667
|
+
description: jsx(DescriptionFieldTemplate, {
|
|
1653
1668
|
id: descriptionId(id),
|
|
1654
1669
|
description: description,
|
|
1655
1670
|
schema: schema,
|
|
@@ -1658,7 +1673,7 @@ function SchemaFieldRender(props) {
|
|
|
1658
1673
|
}),
|
|
1659
1674
|
rawDescription: description,
|
|
1660
1675
|
help: helpComponent,
|
|
1661
|
-
rawHelp: typeof help ===
|
|
1676
|
+
rawHelp: typeof help === 'string' ? help : undefined,
|
|
1662
1677
|
errors: errorsComponent,
|
|
1663
1678
|
rawErrors: hideError ? undefined : __errors,
|
|
1664
1679
|
id: id,
|
|
@@ -1672,7 +1687,7 @@ function SchemaFieldRender(props) {
|
|
|
1672
1687
|
readonly: readonly,
|
|
1673
1688
|
hideError: hideError,
|
|
1674
1689
|
displayLabel: displayLabel,
|
|
1675
|
-
classNames: classNames.join(
|
|
1690
|
+
classNames: classNames.join(' ').trim(),
|
|
1676
1691
|
style: uiOptions.style,
|
|
1677
1692
|
formContext: formContext,
|
|
1678
1693
|
formData: formData,
|
|
@@ -1682,68 +1697,72 @@ function SchemaFieldRender(props) {
|
|
|
1682
1697
|
};
|
|
1683
1698
|
var _AnyOfField = registry.fields.AnyOfField;
|
|
1684
1699
|
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
|
-
|
|
1700
|
+
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:field']) && (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:fieldReplacesAnyOrOneOf']) === true;
|
|
1701
|
+
return jsx(FieldTemplate, _extends({}, fieldProps, {
|
|
1702
|
+
children: jsxs(Fragment, {
|
|
1703
|
+
children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsx(_AnyOfField, {
|
|
1704
|
+
name: name,
|
|
1705
|
+
disabled: disabled,
|
|
1706
|
+
readonly: readonly,
|
|
1707
|
+
hideError: hideError,
|
|
1708
|
+
errorSchema: errorSchema,
|
|
1709
|
+
formData: formData,
|
|
1710
|
+
formContext: formContext,
|
|
1711
|
+
idPrefix: idPrefix,
|
|
1712
|
+
idSchema: idSchema,
|
|
1713
|
+
idSeparator: idSeparator,
|
|
1714
|
+
onBlur: props.onBlur,
|
|
1715
|
+
onChange: props.onChange,
|
|
1716
|
+
onFocus: props.onFocus,
|
|
1717
|
+
options: schema.anyOf.map(function (_schema) {
|
|
1718
|
+
return schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData);
|
|
1719
|
+
}),
|
|
1720
|
+
baseType: schema.type,
|
|
1721
|
+
registry: registry,
|
|
1722
|
+
schema: schema,
|
|
1723
|
+
uiSchema: uiSchema
|
|
1724
|
+
}), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsx(_OneOfField, {
|
|
1725
|
+
name: name,
|
|
1726
|
+
disabled: disabled,
|
|
1727
|
+
readonly: readonly,
|
|
1728
|
+
hideError: hideError,
|
|
1729
|
+
errorSchema: errorSchema,
|
|
1730
|
+
formData: formData,
|
|
1731
|
+
formContext: formContext,
|
|
1732
|
+
idPrefix: idPrefix,
|
|
1733
|
+
idSchema: idSchema,
|
|
1734
|
+
idSeparator: idSeparator,
|
|
1735
|
+
onBlur: props.onBlur,
|
|
1736
|
+
onChange: props.onChange,
|
|
1737
|
+
onFocus: props.onFocus,
|
|
1738
|
+
options: schema.oneOf.map(function (_schema) {
|
|
1739
|
+
return schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData);
|
|
1740
|
+
}),
|
|
1741
|
+
baseType: schema.type,
|
|
1742
|
+
registry: registry,
|
|
1743
|
+
schema: schema,
|
|
1744
|
+
uiSchema: uiSchema
|
|
1745
|
+
})]
|
|
1746
|
+
})
|
|
1747
|
+
}));
|
|
1729
1748
|
}
|
|
1730
1749
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
1731
1750
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
1732
1751
|
*/
|
|
1733
|
-
var SchemaField = /*#__PURE__*/function (
|
|
1734
|
-
_inheritsLoose(SchemaField,
|
|
1752
|
+
var SchemaField = /*#__PURE__*/function (_Component) {
|
|
1753
|
+
_inheritsLoose(SchemaField, _Component);
|
|
1735
1754
|
function SchemaField() {
|
|
1736
|
-
return
|
|
1755
|
+
return _Component.apply(this, arguments) || this;
|
|
1737
1756
|
}
|
|
1738
1757
|
var _proto = SchemaField.prototype;
|
|
1739
1758
|
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
1740
1759
|
return !deepEquals(this.props, nextProps);
|
|
1741
1760
|
};
|
|
1742
1761
|
_proto.render = function render() {
|
|
1743
|
-
return
|
|
1762
|
+
return jsx(SchemaFieldRender, _extends({}, this.props));
|
|
1744
1763
|
};
|
|
1745
1764
|
return SchemaField;
|
|
1746
|
-
}(
|
|
1765
|
+
}(Component);
|
|
1747
1766
|
|
|
1748
1767
|
var _excluded$5 = ["widget", "placeholder"];
|
|
1749
1768
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
@@ -1774,7 +1793,7 @@ function StringField(props) {
|
|
|
1774
1793
|
formContext = registry.formContext,
|
|
1775
1794
|
schemaUtils = registry.schemaUtils;
|
|
1776
1795
|
var enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema) : undefined;
|
|
1777
|
-
var defaultWidget = enumOptions ?
|
|
1796
|
+
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1778
1797
|
if (format && hasWidget(schema, format, widgets)) {
|
|
1779
1798
|
defaultWidget = format;
|
|
1780
1799
|
}
|
|
@@ -1782,16 +1801,17 @@ function StringField(props) {
|
|
|
1782
1801
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1783
1802
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1784
1803
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1785
|
-
placeholder = _getUiOptions$placeho === void 0 ?
|
|
1804
|
+
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1786
1805
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1787
1806
|
var Widget = getWidget(schema, widget, widgets);
|
|
1788
|
-
return
|
|
1807
|
+
return jsx(Widget, {
|
|
1789
1808
|
options: _extends({}, options, {
|
|
1790
1809
|
enumOptions: enumOptions
|
|
1791
1810
|
}),
|
|
1792
1811
|
schema: schema,
|
|
1793
1812
|
uiSchema: uiSchema,
|
|
1794
1813
|
id: idSchema.$id,
|
|
1814
|
+
name: name,
|
|
1795
1815
|
label: title === undefined ? name : title,
|
|
1796
1816
|
value: formData,
|
|
1797
1817
|
onChange: onChange,
|
|
@@ -1856,8 +1876,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1856
1876
|
if (!description || !displayLabel) {
|
|
1857
1877
|
return null;
|
|
1858
1878
|
}
|
|
1859
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
1860
|
-
return
|
|
1879
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
1880
|
+
return jsx(DescriptionFieldTemplate, {
|
|
1861
1881
|
id: descriptionId(idSchema),
|
|
1862
1882
|
description: description,
|
|
1863
1883
|
schema: schema,
|
|
@@ -1892,39 +1912,43 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1892
1912
|
flex: 1,
|
|
1893
1913
|
paddingLeft: 6,
|
|
1894
1914
|
paddingRight: 6,
|
|
1895
|
-
fontWeight:
|
|
1915
|
+
fontWeight: 'bold'
|
|
1896
1916
|
};
|
|
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
|
-
|
|
1917
|
+
return jsxs("div", {
|
|
1918
|
+
className: className,
|
|
1919
|
+
children: [jsx("div", {
|
|
1920
|
+
className: hasToolbar ? 'col-xs-9' : 'col-xs-12',
|
|
1921
|
+
children: children
|
|
1922
|
+
}), hasToolbar && jsx("div", {
|
|
1923
|
+
className: 'col-xs-3 array-item-toolbox',
|
|
1924
|
+
children: jsxs("div", {
|
|
1925
|
+
className: 'btn-group',
|
|
1926
|
+
style: {
|
|
1927
|
+
display: 'flex',
|
|
1928
|
+
justifyContent: 'space-around'
|
|
1929
|
+
},
|
|
1930
|
+
children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
|
|
1931
|
+
style: btnStyle,
|
|
1932
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
1933
|
+
onClick: onReorderClick(index, index - 1),
|
|
1934
|
+
uiSchema: uiSchema,
|
|
1935
|
+
registry: registry
|
|
1936
|
+
}), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
|
|
1937
|
+
style: btnStyle,
|
|
1938
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
1939
|
+
onClick: onReorderClick(index, index + 1),
|
|
1940
|
+
uiSchema: uiSchema,
|
|
1941
|
+
registry: registry
|
|
1942
|
+
}), hasRemove && jsx(RemoveButton, {
|
|
1943
|
+
style: btnStyle,
|
|
1944
|
+
disabled: disabled || readonly,
|
|
1945
|
+
onClick: onDropIndexClick(index),
|
|
1946
|
+
uiSchema: uiSchema,
|
|
1947
|
+
registry: registry
|
|
1948
|
+
})]
|
|
1949
|
+
})
|
|
1950
|
+
})]
|
|
1951
|
+
});
|
|
1928
1952
|
}
|
|
1929
1953
|
|
|
1930
1954
|
var _excluded$4 = ["key"];
|
|
@@ -1946,42 +1970,42 @@ function ArrayFieldTemplate(props) {
|
|
|
1946
1970
|
schema = props.schema,
|
|
1947
1971
|
title = props.title;
|
|
1948
1972
|
var uiOptions = getUiOptions(uiSchema);
|
|
1949
|
-
var ArrayFieldDescriptionTemplate = getTemplate(
|
|
1950
|
-
var ArrayFieldItemTemplate = getTemplate(
|
|
1951
|
-
var ArrayFieldTitleTemplate = getTemplate(
|
|
1973
|
+
var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
1974
|
+
var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
1975
|
+
var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
1952
1976
|
// Button templates are not overridden in the uiSchema
|
|
1953
1977
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
1954
|
-
return
|
|
1978
|
+
return jsxs("fieldset", {
|
|
1955
1979
|
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
|
-
})
|
|
1980
|
+
id: idSchema.$id,
|
|
1981
|
+
children: [jsx(ArrayFieldTitleTemplate, {
|
|
1982
|
+
idSchema: idSchema,
|
|
1983
|
+
title: uiOptions.title || title,
|
|
1984
|
+
required: required,
|
|
1985
|
+
schema: schema,
|
|
1986
|
+
uiSchema: uiSchema,
|
|
1987
|
+
registry: registry
|
|
1988
|
+
}), jsx(ArrayFieldDescriptionTemplate, {
|
|
1989
|
+
idSchema: idSchema,
|
|
1990
|
+
description: uiOptions.description || schema.description,
|
|
1991
|
+
schema: schema,
|
|
1992
|
+
uiSchema: uiSchema,
|
|
1993
|
+
registry: registry
|
|
1994
|
+
}), jsx("div", {
|
|
1995
|
+
className: 'row array-item-list',
|
|
1996
|
+
children: items && items.map(function (_ref) {
|
|
1997
|
+
var key = _ref.key,
|
|
1998
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
1999
|
+
return jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
2000
|
+
})
|
|
2001
|
+
}), canAdd && jsx(AddButton, {
|
|
2002
|
+
className: 'array-item-add',
|
|
2003
|
+
onClick: onAddClick,
|
|
2004
|
+
disabled: disabled || readonly,
|
|
2005
|
+
uiSchema: uiSchema,
|
|
2006
|
+
registry: registry
|
|
2007
|
+
})]
|
|
2008
|
+
});
|
|
1985
2009
|
}
|
|
1986
2010
|
|
|
1987
2011
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
@@ -2002,8 +2026,8 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2002
2026
|
if (!title || !displayLabel) {
|
|
2003
2027
|
return null;
|
|
2004
2028
|
}
|
|
2005
|
-
var TitleFieldTemplate = getTemplate(
|
|
2006
|
-
return
|
|
2029
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
2030
|
+
return jsx(TitleFieldTemplate, {
|
|
2007
2031
|
id: titleId(idSchema),
|
|
2008
2032
|
title: title,
|
|
2009
2033
|
required: required,
|
|
@@ -2013,7 +2037,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2013
2037
|
});
|
|
2014
2038
|
}
|
|
2015
2039
|
|
|
2016
|
-
var _excluded$3 = ["id", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2040
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2017
2041
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2018
2042
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2019
2043
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2029,6 +2053,7 @@ function BaseInputTemplate(props) {
|
|
|
2029
2053
|
onBlur = props.onBlur,
|
|
2030
2054
|
onFocus = props.onFocus,
|
|
2031
2055
|
onChange = props.onChange,
|
|
2056
|
+
onChangeOverride = props.onChangeOverride,
|
|
2032
2057
|
options = props.options,
|
|
2033
2058
|
schema = props.schema,
|
|
2034
2059
|
type = props.type,
|
|
@@ -2036,19 +2061,19 @@ function BaseInputTemplate(props) {
|
|
|
2036
2061
|
// Note: since React 15.2.0 we can't forward unknown element attributes, so we
|
|
2037
2062
|
// exclude the "options" and "schema" ones here.
|
|
2038
2063
|
if (!id) {
|
|
2039
|
-
console.log(
|
|
2064
|
+
console.log('No id for', props);
|
|
2040
2065
|
throw new Error("no id for props " + JSON.stringify(props));
|
|
2041
2066
|
}
|
|
2042
2067
|
var inputProps = _extends({}, rest, getInputProps(schema, type, options));
|
|
2043
2068
|
var inputValue;
|
|
2044
|
-
if (inputProps.type ===
|
|
2045
|
-
inputValue = value || value === 0 ? value :
|
|
2069
|
+
if (inputProps.type === 'number' || inputProps.type === 'integer') {
|
|
2070
|
+
inputValue = value || value === 0 ? value : '';
|
|
2046
2071
|
} else {
|
|
2047
|
-
inputValue = value == null ?
|
|
2072
|
+
inputValue = value == null ? '' : value;
|
|
2048
2073
|
}
|
|
2049
2074
|
var _onChange = useCallback(function (_ref) {
|
|
2050
2075
|
var value = _ref.target.value;
|
|
2051
|
-
return onChange(value ===
|
|
2076
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
2052
2077
|
}, [onChange, options]);
|
|
2053
2078
|
var _onBlur = useCallback(function (_ref2) {
|
|
2054
2079
|
var value = _ref2.target.value;
|
|
@@ -2058,29 +2083,30 @@ function BaseInputTemplate(props) {
|
|
|
2058
2083
|
var value = _ref3.target.value;
|
|
2059
2084
|
return onFocus(id, value);
|
|
2060
2085
|
}, [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
|
-
|
|
2086
|
+
return jsxs(Fragment, {
|
|
2087
|
+
children: [jsx("input", _extends({
|
|
2088
|
+
id: id,
|
|
2089
|
+
name: id,
|
|
2090
|
+
className: 'form-control',
|
|
2091
|
+
readOnly: readonly,
|
|
2092
|
+
disabled: disabled,
|
|
2093
|
+
autoFocus: autofocus,
|
|
2094
|
+
value: inputValue
|
|
2095
|
+
}, inputProps, {
|
|
2096
|
+
list: schema.examples ? examplesId(id) : undefined,
|
|
2097
|
+
onChange: onChangeOverride || _onChange,
|
|
2098
|
+
onBlur: _onBlur,
|
|
2099
|
+
onFocus: _onFocus,
|
|
2100
|
+
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
2101
|
+
})), Array.isArray(schema.examples) && jsx("datalist", {
|
|
2102
|
+
id: examplesId(id),
|
|
2103
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
2104
|
+
return jsx("option", {
|
|
2105
|
+
value: example
|
|
2106
|
+
}, example);
|
|
2107
|
+
})
|
|
2108
|
+
}, "datalist_" + id)]
|
|
2109
|
+
});
|
|
2084
2110
|
}
|
|
2085
2111
|
|
|
2086
2112
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -2095,53 +2121,58 @@ function SubmitButton(_ref) {
|
|
|
2095
2121
|
if (norender) {
|
|
2096
2122
|
return null;
|
|
2097
2123
|
}
|
|
2098
|
-
return
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2124
|
+
return jsx("div", {
|
|
2125
|
+
children: jsx("button", _extends({
|
|
2126
|
+
type: 'submit'
|
|
2127
|
+
}, submitButtonProps, {
|
|
2128
|
+
className: "btn btn-info " + submitButtonProps.className,
|
|
2129
|
+
children: submitText
|
|
2130
|
+
}))
|
|
2131
|
+
});
|
|
2103
2132
|
}
|
|
2104
2133
|
|
|
2105
2134
|
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2106
2135
|
function IconButton(props) {
|
|
2107
2136
|
var _props$iconType = props.iconType,
|
|
2108
|
-
iconType = _props$iconType === void 0 ?
|
|
2137
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
2109
2138
|
icon = props.icon,
|
|
2110
2139
|
className = props.className,
|
|
2111
2140
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
2112
|
-
return
|
|
2113
|
-
type:
|
|
2141
|
+
return jsx("button", _extends({
|
|
2142
|
+
type: 'button',
|
|
2114
2143
|
className: "btn btn-" + iconType + " " + className
|
|
2115
|
-
}, otherProps
|
|
2116
|
-
|
|
2144
|
+
}, otherProps, {
|
|
2145
|
+
children: jsx("i", {
|
|
2146
|
+
className: "glyphicon glyphicon-" + icon
|
|
2147
|
+
})
|
|
2117
2148
|
}));
|
|
2118
2149
|
}
|
|
2119
2150
|
function MoveDownButton(props) {
|
|
2120
2151
|
var translateString = props.registry.translateString;
|
|
2121
|
-
return
|
|
2152
|
+
return jsx(IconButton, _extends({
|
|
2122
2153
|
title: translateString(TranslatableString.MoveDownButton),
|
|
2123
|
-
className:
|
|
2154
|
+
className: 'array-item-move-down'
|
|
2124
2155
|
}, props, {
|
|
2125
|
-
icon:
|
|
2156
|
+
icon: 'arrow-down'
|
|
2126
2157
|
}));
|
|
2127
2158
|
}
|
|
2128
2159
|
function MoveUpButton(props) {
|
|
2129
2160
|
var translateString = props.registry.translateString;
|
|
2130
|
-
return
|
|
2161
|
+
return jsx(IconButton, _extends({
|
|
2131
2162
|
title: translateString(TranslatableString.MoveUpButton),
|
|
2132
|
-
className:
|
|
2163
|
+
className: 'array-item-move-up'
|
|
2133
2164
|
}, props, {
|
|
2134
|
-
icon:
|
|
2165
|
+
icon: 'arrow-up'
|
|
2135
2166
|
}));
|
|
2136
2167
|
}
|
|
2137
2168
|
function RemoveButton(props) {
|
|
2138
2169
|
var translateString = props.registry.translateString;
|
|
2139
|
-
return
|
|
2170
|
+
return jsx(IconButton, _extends({
|
|
2140
2171
|
title: translateString(TranslatableString.RemoveButton),
|
|
2141
|
-
className:
|
|
2172
|
+
className: 'array-item-remove'
|
|
2142
2173
|
}, props, {
|
|
2143
|
-
iconType:
|
|
2144
|
-
icon:
|
|
2174
|
+
iconType: 'danger',
|
|
2175
|
+
icon: 'remove'
|
|
2145
2176
|
}));
|
|
2146
2177
|
}
|
|
2147
2178
|
|
|
@@ -2153,19 +2184,21 @@ function AddButton(_ref) {
|
|
|
2153
2184
|
disabled = _ref.disabled,
|
|
2154
2185
|
registry = _ref.registry;
|
|
2155
2186
|
var translateString = registry.translateString;
|
|
2156
|
-
return
|
|
2157
|
-
className:
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2187
|
+
return jsx("div", {
|
|
2188
|
+
className: 'row',
|
|
2189
|
+
children: jsx("p", {
|
|
2190
|
+
className: "col-xs-3 col-xs-offset-9 text-right " + className,
|
|
2191
|
+
children: jsx(IconButton, {
|
|
2192
|
+
iconType: 'info',
|
|
2193
|
+
icon: 'plus',
|
|
2194
|
+
className: 'btn-add col-xs-12',
|
|
2195
|
+
title: translateString(TranslatableString.AddButton),
|
|
2196
|
+
onClick: onClick,
|
|
2197
|
+
disabled: disabled,
|
|
2198
|
+
registry: registry
|
|
2199
|
+
})
|
|
2200
|
+
})
|
|
2201
|
+
});
|
|
2169
2202
|
}
|
|
2170
2203
|
|
|
2171
2204
|
function buttonTemplates() {
|
|
@@ -2188,16 +2221,18 @@ function DescriptionField(props) {
|
|
|
2188
2221
|
if (!description) {
|
|
2189
2222
|
return null;
|
|
2190
2223
|
}
|
|
2191
|
-
if (typeof description ===
|
|
2192
|
-
return
|
|
2224
|
+
if (typeof description === 'string') {
|
|
2225
|
+
return jsx("p", {
|
|
2193
2226
|
id: id,
|
|
2194
|
-
className:
|
|
2195
|
-
|
|
2227
|
+
className: 'field-description',
|
|
2228
|
+
children: description
|
|
2229
|
+
});
|
|
2196
2230
|
} else {
|
|
2197
|
-
return
|
|
2231
|
+
return jsx("div", {
|
|
2198
2232
|
id: id,
|
|
2199
|
-
className:
|
|
2200
|
-
|
|
2233
|
+
className: 'field-description',
|
|
2234
|
+
children: description
|
|
2235
|
+
});
|
|
2201
2236
|
}
|
|
2202
2237
|
}
|
|
2203
2238
|
|
|
@@ -2209,23 +2244,27 @@ function ErrorList(_ref) {
|
|
|
2209
2244
|
var errors = _ref.errors,
|
|
2210
2245
|
registry = _ref.registry;
|
|
2211
2246
|
var translateString = registry.translateString;
|
|
2212
|
-
return
|
|
2213
|
-
className:
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2247
|
+
return jsxs("div", {
|
|
2248
|
+
className: 'panel panel-danger errors',
|
|
2249
|
+
children: [jsx("div", {
|
|
2250
|
+
className: 'panel-heading',
|
|
2251
|
+
children: jsx("h3", {
|
|
2252
|
+
className: 'panel-title',
|
|
2253
|
+
children: translateString(TranslatableString.ErrorsLabel)
|
|
2254
|
+
})
|
|
2255
|
+
}), jsx("ul", {
|
|
2256
|
+
className: 'list-group',
|
|
2257
|
+
children: errors.map(function (error, i) {
|
|
2258
|
+
return jsx("li", {
|
|
2259
|
+
className: 'list-group-item text-danger',
|
|
2260
|
+
children: error.stack
|
|
2261
|
+
}, i);
|
|
2262
|
+
})
|
|
2263
|
+
})]
|
|
2264
|
+
});
|
|
2226
2265
|
}
|
|
2227
2266
|
|
|
2228
|
-
var REQUIRED_FIELD_SYMBOL$1 =
|
|
2267
|
+
var REQUIRED_FIELD_SYMBOL$1 = '*';
|
|
2229
2268
|
/** Renders a label for a field
|
|
2230
2269
|
*
|
|
2231
2270
|
* @param props - The `LabelProps` for this component
|
|
@@ -2237,12 +2276,14 @@ function Label(props) {
|
|
|
2237
2276
|
if (!label) {
|
|
2238
2277
|
return null;
|
|
2239
2278
|
}
|
|
2240
|
-
return
|
|
2241
|
-
className:
|
|
2242
|
-
htmlFor: id
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2279
|
+
return jsxs("label", {
|
|
2280
|
+
className: 'control-label',
|
|
2281
|
+
htmlFor: id,
|
|
2282
|
+
children: [label, required && jsx("span", {
|
|
2283
|
+
className: 'required',
|
|
2284
|
+
children: REQUIRED_FIELD_SYMBOL$1
|
|
2285
|
+
})]
|
|
2286
|
+
});
|
|
2246
2287
|
}
|
|
2247
2288
|
|
|
2248
2289
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -2263,17 +2304,20 @@ function FieldTemplate(props) {
|
|
|
2263
2304
|
registry = props.registry,
|
|
2264
2305
|
uiSchema = props.uiSchema;
|
|
2265
2306
|
var uiOptions = getUiOptions(uiSchema);
|
|
2266
|
-
var WrapIfAdditionalTemplate = getTemplate(
|
|
2307
|
+
var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
2267
2308
|
if (hidden) {
|
|
2268
|
-
return
|
|
2269
|
-
className:
|
|
2270
|
-
|
|
2309
|
+
return jsx("div", {
|
|
2310
|
+
className: 'hidden',
|
|
2311
|
+
children: children
|
|
2312
|
+
});
|
|
2271
2313
|
}
|
|
2272
|
-
return
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2314
|
+
return jsxs(WrapIfAdditionalTemplate, _extends({}, props, {
|
|
2315
|
+
children: [displayLabel && jsx(Label, {
|
|
2316
|
+
label: label,
|
|
2317
|
+
required: required,
|
|
2318
|
+
id: id
|
|
2319
|
+
}), displayLabel && description ? description : null, children, errors, help]
|
|
2320
|
+
}));
|
|
2277
2321
|
}
|
|
2278
2322
|
|
|
2279
2323
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -2288,17 +2332,20 @@ function FieldErrorTemplate(props) {
|
|
|
2288
2332
|
return null;
|
|
2289
2333
|
}
|
|
2290
2334
|
var id = errorId(idSchema);
|
|
2291
|
-
return
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2335
|
+
return jsx("div", {
|
|
2336
|
+
children: jsx("ul", {
|
|
2337
|
+
id: id,
|
|
2338
|
+
className: 'error-detail bs-callout bs-callout-info',
|
|
2339
|
+
children: errors.filter(function (elem) {
|
|
2340
|
+
return !!elem;
|
|
2341
|
+
}).map(function (error, index) {
|
|
2342
|
+
return jsx("li", {
|
|
2343
|
+
className: 'text-danger',
|
|
2344
|
+
children: error
|
|
2345
|
+
}, index);
|
|
2346
|
+
})
|
|
2347
|
+
})
|
|
2348
|
+
});
|
|
2302
2349
|
}
|
|
2303
2350
|
|
|
2304
2351
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -2312,16 +2359,18 @@ function FieldHelpTemplate(props) {
|
|
|
2312
2359
|
return null;
|
|
2313
2360
|
}
|
|
2314
2361
|
var id = helpId(idSchema);
|
|
2315
|
-
if (typeof help ===
|
|
2316
|
-
return
|
|
2362
|
+
if (typeof help === 'string') {
|
|
2363
|
+
return jsx("p", {
|
|
2317
2364
|
id: id,
|
|
2318
|
-
className:
|
|
2319
|
-
|
|
2365
|
+
className: 'help-block',
|
|
2366
|
+
children: help
|
|
2367
|
+
});
|
|
2320
2368
|
}
|
|
2321
|
-
return
|
|
2369
|
+
return jsx("div", {
|
|
2322
2370
|
id: id,
|
|
2323
|
-
className:
|
|
2324
|
-
|
|
2371
|
+
className: 'help-block',
|
|
2372
|
+
children: help
|
|
2373
|
+
});
|
|
2325
2374
|
}
|
|
2326
2375
|
|
|
2327
2376
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -2344,37 +2393,38 @@ function ObjectFieldTemplate(props) {
|
|
|
2344
2393
|
title = props.title,
|
|
2345
2394
|
uiSchema = props.uiSchema;
|
|
2346
2395
|
var options = getUiOptions(uiSchema);
|
|
2347
|
-
var TitleFieldTemplate = getTemplate(
|
|
2348
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
2396
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
2397
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2349
2398
|
// Button templates are not overridden in the uiSchema
|
|
2350
2399
|
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
|
-
|
|
2400
|
+
return jsxs("fieldset", {
|
|
2401
|
+
id: idSchema.$id,
|
|
2402
|
+
children: [(options.title || title) && jsx(TitleFieldTemplate, {
|
|
2403
|
+
id: titleId(idSchema),
|
|
2404
|
+
title: options.title || title,
|
|
2405
|
+
required: required,
|
|
2406
|
+
schema: schema,
|
|
2407
|
+
uiSchema: uiSchema,
|
|
2408
|
+
registry: registry
|
|
2409
|
+
}), (options.description || description) && jsx(DescriptionFieldTemplate, {
|
|
2410
|
+
id: descriptionId(idSchema),
|
|
2411
|
+
description: options.description || description,
|
|
2412
|
+
schema: schema,
|
|
2413
|
+
uiSchema: uiSchema,
|
|
2414
|
+
registry: registry
|
|
2415
|
+
}), properties.map(function (prop) {
|
|
2416
|
+
return prop.content;
|
|
2417
|
+
}), canExpand(schema, uiSchema, formData) && jsx(AddButton, {
|
|
2418
|
+
className: 'object-property-expand',
|
|
2419
|
+
onClick: onAddClick(schema),
|
|
2420
|
+
disabled: disabled || readonly,
|
|
2421
|
+
uiSchema: uiSchema,
|
|
2422
|
+
registry: registry
|
|
2423
|
+
})]
|
|
2424
|
+
});
|
|
2375
2425
|
}
|
|
2376
2426
|
|
|
2377
|
-
var REQUIRED_FIELD_SYMBOL =
|
|
2427
|
+
var REQUIRED_FIELD_SYMBOL = '*';
|
|
2378
2428
|
/** The `TitleField` is the template to use to render the title of a field
|
|
2379
2429
|
*
|
|
2380
2430
|
* @param props - The `TitleFieldProps` for this component
|
|
@@ -2383,11 +2433,13 @@ function TitleField(props) {
|
|
|
2383
2433
|
var id = props.id,
|
|
2384
2434
|
title = props.title,
|
|
2385
2435
|
required = props.required;
|
|
2386
|
-
return
|
|
2387
|
-
id: id
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2436
|
+
return jsxs("legend", {
|
|
2437
|
+
id: id,
|
|
2438
|
+
children: [title, required && jsx("span", {
|
|
2439
|
+
className: 'required',
|
|
2440
|
+
children: REQUIRED_FIELD_SYMBOL
|
|
2441
|
+
})]
|
|
2442
|
+
});
|
|
2391
2443
|
}
|
|
2392
2444
|
|
|
2393
2445
|
/** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
|
|
@@ -2411,9 +2463,16 @@ function UnsupportedField(props) {
|
|
|
2411
2463
|
translateEnum = translateEnum === TranslatableString.UnsupportedField ? TranslatableString.UnsupportedFieldWithReason : TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2412
2464
|
translateParams.push(reason);
|
|
2413
2465
|
}
|
|
2414
|
-
return
|
|
2415
|
-
className:
|
|
2416
|
-
|
|
2466
|
+
return jsxs("div", {
|
|
2467
|
+
className: 'unsupported-field',
|
|
2468
|
+
children: [jsx("p", {
|
|
2469
|
+
children: jsx(Markdown, {
|
|
2470
|
+
children: translateString(translateEnum, translateParams)
|
|
2471
|
+
})
|
|
2472
|
+
}), schema && jsx("pre", {
|
|
2473
|
+
children: JSON.stringify(schema, null, 2)
|
|
2474
|
+
})]
|
|
2475
|
+
});
|
|
2417
2476
|
}
|
|
2418
2477
|
|
|
2419
2478
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -2442,46 +2501,53 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2442
2501
|
var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
2443
2502
|
var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2444
2503
|
if (!additional) {
|
|
2445
|
-
return
|
|
2504
|
+
return jsx("div", {
|
|
2446
2505
|
className: classNames,
|
|
2447
|
-
style: style
|
|
2448
|
-
|
|
2506
|
+
style: style,
|
|
2507
|
+
children: children
|
|
2508
|
+
});
|
|
2449
2509
|
}
|
|
2450
|
-
return
|
|
2510
|
+
return jsx("div", {
|
|
2451
2511
|
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
|
-
|
|
2512
|
+
style: style,
|
|
2513
|
+
children: jsxs("div", {
|
|
2514
|
+
className: 'row',
|
|
2515
|
+
children: [jsx("div", {
|
|
2516
|
+
className: 'col-xs-5 form-additional',
|
|
2517
|
+
children: jsxs("div", {
|
|
2518
|
+
className: 'form-group',
|
|
2519
|
+
children: [jsx(Label, {
|
|
2520
|
+
label: keyLabel,
|
|
2521
|
+
required: required,
|
|
2522
|
+
id: id + "-key"
|
|
2523
|
+
}), jsx("input", {
|
|
2524
|
+
className: 'form-control',
|
|
2525
|
+
type: 'text',
|
|
2526
|
+
id: id + "-key",
|
|
2527
|
+
onBlur: function onBlur(event) {
|
|
2528
|
+
return onKeyChange(event.target.value);
|
|
2529
|
+
},
|
|
2530
|
+
defaultValue: label
|
|
2531
|
+
})]
|
|
2532
|
+
})
|
|
2533
|
+
}), jsx("div", {
|
|
2534
|
+
className: 'form-additional form-group col-xs-5',
|
|
2535
|
+
children: children
|
|
2536
|
+
}), jsx("div", {
|
|
2537
|
+
className: 'col-xs-2',
|
|
2538
|
+
children: jsx(RemoveButton, {
|
|
2539
|
+
className: 'array-item-remove btn-block',
|
|
2540
|
+
style: {
|
|
2541
|
+
border: '0'
|
|
2542
|
+
},
|
|
2543
|
+
disabled: disabled || readonly,
|
|
2544
|
+
onClick: onDropPropertyClick(label),
|
|
2545
|
+
uiSchema: uiSchema,
|
|
2546
|
+
registry: registry
|
|
2547
|
+
})
|
|
2548
|
+
})]
|
|
2549
|
+
})
|
|
2550
|
+
});
|
|
2485
2551
|
}
|
|
2486
2552
|
|
|
2487
2553
|
function templates() {
|
|
@@ -2530,29 +2596,29 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
2530
2596
|
minute = state.minute,
|
|
2531
2597
|
second = state.second;
|
|
2532
2598
|
var data = [{
|
|
2533
|
-
type:
|
|
2599
|
+
type: 'year',
|
|
2534
2600
|
range: yearsRange,
|
|
2535
2601
|
value: year
|
|
2536
2602
|
}, {
|
|
2537
|
-
type:
|
|
2603
|
+
type: 'month',
|
|
2538
2604
|
range: [1, 12],
|
|
2539
2605
|
value: month
|
|
2540
2606
|
}, {
|
|
2541
|
-
type:
|
|
2607
|
+
type: 'day',
|
|
2542
2608
|
range: [1, 31],
|
|
2543
2609
|
value: day
|
|
2544
2610
|
}];
|
|
2545
2611
|
if (time) {
|
|
2546
2612
|
data.push({
|
|
2547
|
-
type:
|
|
2613
|
+
type: 'hour',
|
|
2548
2614
|
range: [0, 23],
|
|
2549
2615
|
value: hour
|
|
2550
2616
|
}, {
|
|
2551
|
-
type:
|
|
2617
|
+
type: 'minute',
|
|
2552
2618
|
range: [0, 59],
|
|
2553
2619
|
value: minute
|
|
2554
2620
|
}, {
|
|
2555
|
-
type:
|
|
2621
|
+
type: 'second',
|
|
2556
2622
|
range: [0, 59],
|
|
2557
2623
|
value: second
|
|
2558
2624
|
});
|
|
@@ -2565,20 +2631,22 @@ function DateElement(_ref) {
|
|
|
2565
2631
|
value = _ref.value,
|
|
2566
2632
|
select = _ref.select,
|
|
2567
2633
|
rootId = _ref.rootId,
|
|
2634
|
+
name = _ref.name,
|
|
2568
2635
|
disabled = _ref.disabled,
|
|
2569
2636
|
readonly = _ref.readonly,
|
|
2570
2637
|
autofocus = _ref.autofocus,
|
|
2571
2638
|
registry = _ref.registry,
|
|
2572
2639
|
onBlur = _ref.onBlur,
|
|
2573
2640
|
onFocus = _ref.onFocus;
|
|
2574
|
-
var id = rootId +
|
|
2641
|
+
var id = rootId + '_' + type;
|
|
2575
2642
|
var SelectWidget = registry.widgets.SelectWidget;
|
|
2576
|
-
return
|
|
2643
|
+
return jsx(SelectWidget, {
|
|
2577
2644
|
schema: {
|
|
2578
|
-
type:
|
|
2645
|
+
type: 'integer'
|
|
2579
2646
|
},
|
|
2580
2647
|
id: id,
|
|
2581
|
-
|
|
2648
|
+
name: name,
|
|
2649
|
+
className: 'form-control',
|
|
2582
2650
|
options: {
|
|
2583
2651
|
enumOptions: rangeOptions(range[0], range[1])
|
|
2584
2652
|
},
|
|
@@ -2593,7 +2661,7 @@ function DateElement(_ref) {
|
|
|
2593
2661
|
onBlur: onBlur,
|
|
2594
2662
|
onFocus: onFocus,
|
|
2595
2663
|
registry: registry,
|
|
2596
|
-
label:
|
|
2664
|
+
label: '',
|
|
2597
2665
|
"aria-describedby": ariaDescribedByIds(rootId)
|
|
2598
2666
|
});
|
|
2599
2667
|
}
|
|
@@ -2611,6 +2679,7 @@ function AltDateWidget(_ref2) {
|
|
|
2611
2679
|
autofocus = _ref2$autofocus === void 0 ? false : _ref2$autofocus,
|
|
2612
2680
|
options = _ref2.options,
|
|
2613
2681
|
id = _ref2.id,
|
|
2682
|
+
name = _ref2.name,
|
|
2614
2683
|
registry = _ref2.registry,
|
|
2615
2684
|
onBlur = _ref2.onBlur,
|
|
2616
2685
|
onFocus = _ref2.onFocus,
|
|
@@ -2650,39 +2719,45 @@ function AltDateWidget(_ref2) {
|
|
|
2650
2719
|
if (disabled || readonly) {
|
|
2651
2720
|
return;
|
|
2652
2721
|
}
|
|
2653
|
-
setState(parseDateString(
|
|
2722
|
+
setState(parseDateString('', time));
|
|
2654
2723
|
onChange(undefined);
|
|
2655
2724
|
}, [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
|
-
|
|
2725
|
+
return jsxs("ul", {
|
|
2726
|
+
className: 'list-inline',
|
|
2727
|
+
children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2728
|
+
return jsx("li", {
|
|
2729
|
+
className: 'list-inline-item',
|
|
2730
|
+
children: jsx(DateElement, _extends({
|
|
2731
|
+
rootId: id,
|
|
2732
|
+
name: name,
|
|
2733
|
+
select: handleChange
|
|
2734
|
+
}, elemProps, {
|
|
2735
|
+
disabled: disabled,
|
|
2736
|
+
readonly: readonly,
|
|
2737
|
+
registry: registry,
|
|
2738
|
+
onBlur: onBlur,
|
|
2739
|
+
onFocus: onFocus,
|
|
2740
|
+
autofocus: autofocus && i === 0
|
|
2741
|
+
}))
|
|
2742
|
+
}, i);
|
|
2743
|
+
}), (options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && jsx("li", {
|
|
2744
|
+
className: 'list-inline-item',
|
|
2745
|
+
children: jsx("a", {
|
|
2746
|
+
href: '#',
|
|
2747
|
+
className: 'btn btn-info btn-now',
|
|
2748
|
+
onClick: handleSetNow,
|
|
2749
|
+
children: translateString(TranslatableString.NowLabel)
|
|
2750
|
+
})
|
|
2751
|
+
}), (options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && jsx("li", {
|
|
2752
|
+
className: 'list-inline-item',
|
|
2753
|
+
children: jsx("a", {
|
|
2754
|
+
href: '#',
|
|
2755
|
+
className: 'btn btn-warning btn-clear',
|
|
2756
|
+
onClick: handleClear,
|
|
2757
|
+
children: translateString(TranslatableString.ClearLabel)
|
|
2758
|
+
})
|
|
2759
|
+
})]
|
|
2760
|
+
});
|
|
2686
2761
|
}
|
|
2687
2762
|
|
|
2688
2763
|
var _excluded$1 = ["time"];
|
|
@@ -2696,7 +2771,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2696
2771
|
time = _ref$time === void 0 ? true : _ref$time,
|
|
2697
2772
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2698
2773
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
2699
|
-
return
|
|
2774
|
+
return jsx(AltDateWidget, _extends({
|
|
2700
2775
|
time: time
|
|
2701
2776
|
}, props));
|
|
2702
2777
|
}
|
|
@@ -2721,7 +2796,7 @@ function CheckboxWidget(_ref) {
|
|
|
2721
2796
|
onFocus = _ref.onFocus,
|
|
2722
2797
|
onChange = _ref.onChange,
|
|
2723
2798
|
registry = _ref.registry;
|
|
2724
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
2799
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2725
2800
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
2726
2801
|
// the "required" attribute if the field value must be "true", due to the
|
|
2727
2802
|
// "const" or "enum" keywords
|
|
@@ -2735,27 +2810,32 @@ function CheckboxWidget(_ref) {
|
|
|
2735
2810
|
var handleFocus = useCallback(function (event) {
|
|
2736
2811
|
return onFocus(id, event.target.checked);
|
|
2737
2812
|
}, [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
|
-
|
|
2813
|
+
return jsxs("div", {
|
|
2814
|
+
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2815
|
+
children: [schema.description && jsx(DescriptionFieldTemplate, {
|
|
2816
|
+
id: descriptionId(id),
|
|
2817
|
+
description: schema.description,
|
|
2818
|
+
schema: schema,
|
|
2819
|
+
uiSchema: uiSchema,
|
|
2820
|
+
registry: registry
|
|
2821
|
+
}), jsxs("label", {
|
|
2822
|
+
children: [jsx("input", {
|
|
2823
|
+
type: 'checkbox',
|
|
2824
|
+
id: id,
|
|
2825
|
+
name: id,
|
|
2826
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
2827
|
+
required: required,
|
|
2828
|
+
disabled: disabled || readonly,
|
|
2829
|
+
autoFocus: autofocus,
|
|
2830
|
+
onChange: handleChange,
|
|
2831
|
+
onBlur: handleBlur,
|
|
2832
|
+
onFocus: handleFocus,
|
|
2833
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
2834
|
+
}), jsx("span", {
|
|
2835
|
+
children: label
|
|
2836
|
+
})]
|
|
2837
|
+
})]
|
|
2838
|
+
});
|
|
2759
2839
|
}
|
|
2760
2840
|
|
|
2761
2841
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
@@ -2788,41 +2868,48 @@ function CheckboxesWidget(_ref) {
|
|
|
2788
2868
|
var value = _ref3.target.value;
|
|
2789
2869
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2790
2870
|
}, [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
|
-
|
|
2871
|
+
return jsx("div", {
|
|
2872
|
+
className: 'checkboxes',
|
|
2873
|
+
id: id,
|
|
2874
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2875
|
+
var checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
2876
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2877
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
2878
|
+
var handleChange = function handleChange(event) {
|
|
2879
|
+
if (event.target.checked) {
|
|
2880
|
+
onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
2881
|
+
} else {
|
|
2882
|
+
onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
2883
|
+
}
|
|
2884
|
+
};
|
|
2885
|
+
var checkbox = jsxs("span", {
|
|
2886
|
+
children: [jsx("input", {
|
|
2887
|
+
type: 'checkbox',
|
|
2888
|
+
id: optionId(id, index),
|
|
2889
|
+
name: id,
|
|
2890
|
+
checked: checked,
|
|
2891
|
+
value: String(index),
|
|
2892
|
+
disabled: disabled || itemDisabled || readonly,
|
|
2893
|
+
autoFocus: autofocus && index === 0,
|
|
2894
|
+
onChange: handleChange,
|
|
2895
|
+
onBlur: handleBlur,
|
|
2896
|
+
onFocus: handleFocus,
|
|
2897
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
2898
|
+
}), jsx("span", {
|
|
2899
|
+
children: option.label
|
|
2900
|
+
})]
|
|
2901
|
+
});
|
|
2902
|
+
return inline ? jsx("label", {
|
|
2903
|
+
className: "checkbox-inline " + disabledCls,
|
|
2904
|
+
children: checkbox
|
|
2905
|
+
}, index) : jsx("div", {
|
|
2906
|
+
className: "checkbox " + disabledCls,
|
|
2907
|
+
children: jsx("label", {
|
|
2908
|
+
children: checkbox
|
|
2909
|
+
})
|
|
2910
|
+
}, index);
|
|
2911
|
+
})
|
|
2912
|
+
});
|
|
2826
2913
|
}
|
|
2827
2914
|
|
|
2828
2915
|
/** The `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
|
|
@@ -2835,9 +2922,9 @@ function ColorWidget(props) {
|
|
|
2835
2922
|
readonly = props.readonly,
|
|
2836
2923
|
options = props.options,
|
|
2837
2924
|
registry = props.registry;
|
|
2838
|
-
var BaseInputTemplate = getTemplate(
|
|
2839
|
-
return
|
|
2840
|
-
type:
|
|
2925
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2926
|
+
return jsx(BaseInputTemplate, _extends({
|
|
2927
|
+
type: 'color'
|
|
2841
2928
|
}, props, {
|
|
2842
2929
|
disabled: disabled || readonly
|
|
2843
2930
|
}));
|
|
@@ -2852,12 +2939,12 @@ function DateWidget(props) {
|
|
|
2852
2939
|
var onChange = props.onChange,
|
|
2853
2940
|
options = props.options,
|
|
2854
2941
|
registry = props.registry;
|
|
2855
|
-
var BaseInputTemplate = getTemplate(
|
|
2942
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2856
2943
|
var handleChange = useCallback(function (value) {
|
|
2857
2944
|
return onChange(value || undefined);
|
|
2858
2945
|
}, [onChange]);
|
|
2859
|
-
return
|
|
2860
|
-
type:
|
|
2946
|
+
return jsx(BaseInputTemplate, _extends({
|
|
2947
|
+
type: 'date'
|
|
2861
2948
|
}, props, {
|
|
2862
2949
|
onChange: handleChange
|
|
2863
2950
|
}));
|
|
@@ -2873,9 +2960,9 @@ function DateTimeWidget(props) {
|
|
|
2873
2960
|
value = props.value,
|
|
2874
2961
|
options = props.options,
|
|
2875
2962
|
registry = props.registry;
|
|
2876
|
-
var BaseInputTemplate = getTemplate(
|
|
2877
|
-
return
|
|
2878
|
-
type:
|
|
2963
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2964
|
+
return jsx(BaseInputTemplate, _extends({
|
|
2965
|
+
type: 'datetime-local'
|
|
2879
2966
|
}, props, {
|
|
2880
2967
|
value: utcToLocal(value),
|
|
2881
2968
|
onChange: function onChange(value) {
|
|
@@ -2891,9 +2978,9 @@ function DateTimeWidget(props) {
|
|
|
2891
2978
|
function EmailWidget(props) {
|
|
2892
2979
|
var options = props.options,
|
|
2893
2980
|
registry = props.registry;
|
|
2894
|
-
var BaseInputTemplate = getTemplate(
|
|
2895
|
-
return
|
|
2896
|
-
type:
|
|
2981
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2982
|
+
return jsx(BaseInputTemplate, _extends({
|
|
2983
|
+
type: 'email'
|
|
2897
2984
|
}, props));
|
|
2898
2985
|
}
|
|
2899
2986
|
|
|
@@ -2901,7 +2988,7 @@ function addNameToDataURL(dataURL, name) {
|
|
|
2901
2988
|
if (dataURL === null) {
|
|
2902
2989
|
return null;
|
|
2903
2990
|
}
|
|
2904
|
-
return dataURL.replace(
|
|
2991
|
+
return dataURL.replace(';base64', ";name=" + encodeURIComponent(name) + ";base64");
|
|
2905
2992
|
}
|
|
2906
2993
|
function processFile(file) {
|
|
2907
2994
|
var name = file.name,
|
|
@@ -2912,7 +2999,7 @@ function processFile(file) {
|
|
|
2912
2999
|
reader.onerror = reject;
|
|
2913
3000
|
reader.onload = function (event) {
|
|
2914
3001
|
var _event$target;
|
|
2915
|
-
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) ===
|
|
3002
|
+
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) === 'string') {
|
|
2916
3003
|
resolve({
|
|
2917
3004
|
dataURL: addNameToDataURL(event.target.result, name),
|
|
2918
3005
|
name: name,
|
|
@@ -2941,20 +3028,23 @@ function FilesInfo(_ref) {
|
|
|
2941
3028
|
return null;
|
|
2942
3029
|
}
|
|
2943
3030
|
var translateString = registry.translateString;
|
|
2944
|
-
return
|
|
2945
|
-
className:
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
3031
|
+
return jsx("ul", {
|
|
3032
|
+
className: 'file-info',
|
|
3033
|
+
children: filesInfo.map(function (fileInfo, key) {
|
|
3034
|
+
var name = fileInfo.name,
|
|
3035
|
+
size = fileInfo.size,
|
|
3036
|
+
type = fileInfo.type;
|
|
3037
|
+
return jsx("li", {
|
|
3038
|
+
children: jsx(Markdown, {
|
|
3039
|
+
children: translateString(TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3040
|
+
})
|
|
3041
|
+
}, key);
|
|
3042
|
+
})
|
|
3043
|
+
});
|
|
2954
3044
|
}
|
|
2955
3045
|
function extractFileInfo(dataURLs) {
|
|
2956
3046
|
return dataURLs.filter(function (dataURL) {
|
|
2957
|
-
return
|
|
3047
|
+
return dataURL;
|
|
2958
3048
|
}).map(function (dataURL) {
|
|
2959
3049
|
var _dataURItoBlob = dataURItoBlob(dataURL),
|
|
2960
3050
|
blob = _dataURItoBlob.blob,
|
|
@@ -2970,17 +3060,15 @@ function extractFileInfo(dataURLs) {
|
|
|
2970
3060
|
* The `FileWidget` is a widget for rendering file upload fields.
|
|
2971
3061
|
* It is typically used with a string property with data-url format.
|
|
2972
3062
|
*/
|
|
2973
|
-
function FileWidget(
|
|
2974
|
-
var
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
options = _ref2.options,
|
|
2983
|
-
registry = _ref2.registry;
|
|
3063
|
+
function FileWidget(props) {
|
|
3064
|
+
var disabled = props.disabled,
|
|
3065
|
+
readonly = props.readonly,
|
|
3066
|
+
multiple = props.multiple,
|
|
3067
|
+
onChange = props.onChange,
|
|
3068
|
+
value = props.value,
|
|
3069
|
+
options = props.options,
|
|
3070
|
+
registry = props.registry;
|
|
3071
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
2984
3072
|
var extractedFilesInfo = useMemo(function () {
|
|
2985
3073
|
return Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value]);
|
|
2986
3074
|
}, [value]);
|
|
@@ -3003,21 +3091,18 @@ function FileWidget(_ref2) {
|
|
|
3003
3091
|
}
|
|
3004
3092
|
});
|
|
3005
3093
|
}, [multiple, onChange]);
|
|
3006
|
-
return
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
})
|
|
3018
|
-
filesInfo: filesInfo,
|
|
3019
|
-
registry: registry
|
|
3020
|
-
}));
|
|
3094
|
+
return jsxs("div", {
|
|
3095
|
+
children: [jsx(BaseInputTemplate, _extends({}, props, {
|
|
3096
|
+
disabled: disabled || readonly,
|
|
3097
|
+
type: 'file',
|
|
3098
|
+
onChangeOverride: handleChange,
|
|
3099
|
+
value: '',
|
|
3100
|
+
accept: options.accept ? String(options.accept) : undefined
|
|
3101
|
+
})), jsx(FilesInfo, {
|
|
3102
|
+
filesInfo: filesInfo,
|
|
3103
|
+
registry: registry
|
|
3104
|
+
})]
|
|
3105
|
+
});
|
|
3021
3106
|
}
|
|
3022
3107
|
|
|
3023
3108
|
/** The `HiddenWidget` is a widget for rendering a hidden input field.
|
|
@@ -3028,11 +3113,11 @@ function FileWidget(_ref2) {
|
|
|
3028
3113
|
function HiddenWidget(_ref) {
|
|
3029
3114
|
var id = _ref.id,
|
|
3030
3115
|
value = _ref.value;
|
|
3031
|
-
return
|
|
3032
|
-
type:
|
|
3116
|
+
return jsx("input", {
|
|
3117
|
+
type: 'hidden',
|
|
3033
3118
|
id: id,
|
|
3034
3119
|
name: id,
|
|
3035
|
-
value: typeof value ===
|
|
3120
|
+
value: typeof value === 'undefined' ? '' : value
|
|
3036
3121
|
});
|
|
3037
3122
|
}
|
|
3038
3123
|
|
|
@@ -3043,9 +3128,9 @@ function HiddenWidget(_ref) {
|
|
|
3043
3128
|
function PasswordWidget(props) {
|
|
3044
3129
|
var options = props.options,
|
|
3045
3130
|
registry = props.registry;
|
|
3046
|
-
var BaseInputTemplate = getTemplate(
|
|
3047
|
-
return
|
|
3048
|
-
type:
|
|
3131
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3132
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3133
|
+
type: 'password'
|
|
3049
3134
|
}, props));
|
|
3050
3135
|
}
|
|
3051
3136
|
|
|
@@ -3080,38 +3165,45 @@ function RadioWidget(_ref) {
|
|
|
3080
3165
|
var value = _ref3.target.value;
|
|
3081
3166
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3082
3167
|
}, [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
|
-
|
|
3168
|
+
return jsx("div", {
|
|
3169
|
+
className: 'field-radio-group',
|
|
3170
|
+
id: id,
|
|
3171
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
3172
|
+
var checked = enumOptionsIsSelected(option.value, value);
|
|
3173
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3174
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
3175
|
+
var handleChange = function handleChange() {
|
|
3176
|
+
return onChange(option.value);
|
|
3177
|
+
};
|
|
3178
|
+
var radio = jsxs("span", {
|
|
3179
|
+
children: [jsx("input", {
|
|
3180
|
+
type: 'radio',
|
|
3181
|
+
id: optionId(id, i),
|
|
3182
|
+
checked: checked,
|
|
3183
|
+
name: name,
|
|
3184
|
+
required: required,
|
|
3185
|
+
value: String(i),
|
|
3186
|
+
disabled: disabled || itemDisabled || readonly,
|
|
3187
|
+
autoFocus: autofocus && i === 0,
|
|
3188
|
+
onChange: handleChange,
|
|
3189
|
+
onBlur: handleBlur,
|
|
3190
|
+
onFocus: handleFocus,
|
|
3191
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
3192
|
+
}), jsx("span", {
|
|
3193
|
+
children: option.label
|
|
3194
|
+
})]
|
|
3195
|
+
});
|
|
3196
|
+
return inline ? jsx("label", {
|
|
3197
|
+
className: "radio-inline " + disabledCls,
|
|
3198
|
+
children: radio
|
|
3199
|
+
}, i) : jsx("div", {
|
|
3200
|
+
className: "radio " + disabledCls,
|
|
3201
|
+
children: jsx("label", {
|
|
3202
|
+
children: radio
|
|
3203
|
+
})
|
|
3204
|
+
}, i);
|
|
3205
|
+
})
|
|
3206
|
+
});
|
|
3115
3207
|
}
|
|
3116
3208
|
|
|
3117
3209
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -3122,13 +3214,15 @@ function RadioWidget(_ref) {
|
|
|
3122
3214
|
function RangeWidget(props) {
|
|
3123
3215
|
var value = props.value,
|
|
3124
3216
|
BaseInputTemplate = props.registry.templates.BaseInputTemplate;
|
|
3125
|
-
return
|
|
3126
|
-
className:
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3217
|
+
return jsxs("div", {
|
|
3218
|
+
className: 'field-range-wrapper',
|
|
3219
|
+
children: [jsx(BaseInputTemplate, _extends({
|
|
3220
|
+
type: 'range'
|
|
3221
|
+
}, props)), jsx("span", {
|
|
3222
|
+
className: 'range-view',
|
|
3223
|
+
children: value
|
|
3224
|
+
})]
|
|
3225
|
+
});
|
|
3132
3226
|
}
|
|
3133
3227
|
|
|
3134
3228
|
function getValue(event, multiple) {
|
|
@@ -3165,7 +3259,7 @@ function SelectWidget(_ref) {
|
|
|
3165
3259
|
var enumOptions = options.enumOptions,
|
|
3166
3260
|
enumDisabled = options.enumDisabled,
|
|
3167
3261
|
optEmptyVal = options.emptyValue;
|
|
3168
|
-
var emptyValue = multiple ? [] :
|
|
3262
|
+
var emptyValue = multiple ? [] : '';
|
|
3169
3263
|
var handleFocus = useCallback(function (event) {
|
|
3170
3264
|
var newValue = getValue(event, multiple);
|
|
3171
3265
|
return onFocus(id, enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
@@ -3179,31 +3273,33 @@ function SelectWidget(_ref) {
|
|
|
3179
3273
|
return onChange(enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3180
3274
|
}, [onChange, schema, multiple, options]);
|
|
3181
3275
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
3182
|
-
return
|
|
3276
|
+
return jsxs("select", {
|
|
3183
3277
|
id: id,
|
|
3184
3278
|
name: id,
|
|
3185
3279
|
multiple: multiple,
|
|
3186
|
-
className:
|
|
3187
|
-
value: typeof selectedIndexes ===
|
|
3280
|
+
className: 'form-control',
|
|
3281
|
+
value: typeof selectedIndexes === 'undefined' ? emptyValue : selectedIndexes,
|
|
3188
3282
|
required: required,
|
|
3189
3283
|
disabled: disabled || readonly,
|
|
3190
3284
|
autoFocus: autofocus,
|
|
3191
3285
|
onBlur: handleBlur,
|
|
3192
3286
|
onFocus: handleFocus,
|
|
3193
3287
|
onChange: handleChange,
|
|
3194
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3288
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
3289
|
+
children: [!multiple && schema["default"] === undefined && jsx("option", {
|
|
3290
|
+
value: '',
|
|
3291
|
+
children: placeholder
|
|
3292
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
3293
|
+
var value = _ref2.value,
|
|
3294
|
+
label = _ref2.label;
|
|
3295
|
+
var disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
|
|
3296
|
+
return jsx("option", {
|
|
3297
|
+
value: String(i),
|
|
3298
|
+
disabled: disabled,
|
|
3299
|
+
children: label
|
|
3300
|
+
}, i);
|
|
3301
|
+
})]
|
|
3302
|
+
});
|
|
3207
3303
|
}
|
|
3208
3304
|
|
|
3209
3305
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -3226,7 +3322,7 @@ function TextareaWidget(_ref) {
|
|
|
3226
3322
|
onFocus = _ref.onFocus;
|
|
3227
3323
|
var handleChange = useCallback(function (_ref2) {
|
|
3228
3324
|
var value = _ref2.target.value;
|
|
3229
|
-
return onChange(value ===
|
|
3325
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
3230
3326
|
}, [onChange, options.emptyValue]);
|
|
3231
3327
|
var handleBlur = useCallback(function (_ref3) {
|
|
3232
3328
|
var value = _ref3.target.value;
|
|
@@ -3236,11 +3332,11 @@ function TextareaWidget(_ref) {
|
|
|
3236
3332
|
var value = _ref4.target.value;
|
|
3237
3333
|
return onFocus(id, value);
|
|
3238
3334
|
}, [id, onFocus]);
|
|
3239
|
-
return
|
|
3335
|
+
return jsx("textarea", {
|
|
3240
3336
|
id: id,
|
|
3241
3337
|
name: id,
|
|
3242
|
-
className:
|
|
3243
|
-
value: value ? value :
|
|
3338
|
+
className: 'form-control',
|
|
3339
|
+
value: value ? value : '',
|
|
3244
3340
|
placeholder: placeholder,
|
|
3245
3341
|
required: required,
|
|
3246
3342
|
disabled: disabled,
|
|
@@ -3265,8 +3361,8 @@ TextareaWidget.defaultProps = {
|
|
|
3265
3361
|
function TextWidget(props) {
|
|
3266
3362
|
var options = props.options,
|
|
3267
3363
|
registry = props.registry;
|
|
3268
|
-
var BaseInputTemplate = getTemplate(
|
|
3269
|
-
return
|
|
3364
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3365
|
+
return jsx(BaseInputTemplate, _extends({}, props));
|
|
3270
3366
|
}
|
|
3271
3367
|
|
|
3272
3368
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
@@ -3276,9 +3372,9 @@ function TextWidget(props) {
|
|
|
3276
3372
|
function URLWidget(props) {
|
|
3277
3373
|
var options = props.options,
|
|
3278
3374
|
registry = props.registry;
|
|
3279
|
-
var BaseInputTemplate = getTemplate(
|
|
3280
|
-
return
|
|
3281
|
-
type:
|
|
3375
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3376
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3377
|
+
type: 'url'
|
|
3282
3378
|
}, props));
|
|
3283
3379
|
}
|
|
3284
3380
|
|
|
@@ -3289,9 +3385,9 @@ function URLWidget(props) {
|
|
|
3289
3385
|
function UpDownWidget(props) {
|
|
3290
3386
|
var options = props.options,
|
|
3291
3387
|
registry = props.registry;
|
|
3292
|
-
var BaseInputTemplate = getTemplate(
|
|
3293
|
-
return
|
|
3294
|
-
type:
|
|
3388
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3389
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3390
|
+
type: 'number'
|
|
3295
3391
|
}, props));
|
|
3296
3392
|
}
|
|
3297
3393
|
|
|
@@ -3352,7 +3448,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3352
3448
|
_this.formElement = void 0;
|
|
3353
3449
|
_this.getUsedFormData = function (formData, fields) {
|
|
3354
3450
|
// For the case of a single input form
|
|
3355
|
-
if (fields.length === 0 && typeof formData !==
|
|
3451
|
+
if (fields.length === 0 && typeof formData !== 'object') {
|
|
3356
3452
|
return formData;
|
|
3357
3453
|
}
|
|
3358
3454
|
// _pick has incorrect type definition, it works with string[][], because lodash/hasIn supports it
|
|
@@ -3373,22 +3469,22 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3373
3469
|
paths = [[]];
|
|
3374
3470
|
}
|
|
3375
3471
|
Object.keys(_obj).forEach(function (key) {
|
|
3376
|
-
if (typeof _obj[key] ===
|
|
3472
|
+
if (typeof _obj[key] === 'object') {
|
|
3377
3473
|
var newPaths = paths.map(function (path) {
|
|
3378
3474
|
return [].concat(path, [key]);
|
|
3379
3475
|
});
|
|
3380
3476
|
// If an object is marked with additionalProperties, all its keys are valid
|
|
3381
|
-
if (_obj[key][RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !==
|
|
3477
|
+
if (_obj[key][RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !== '') {
|
|
3382
3478
|
acc.push(_obj[key][NAME_KEY]);
|
|
3383
3479
|
} else {
|
|
3384
3480
|
getAllPaths(_obj[key], acc, newPaths);
|
|
3385
3481
|
}
|
|
3386
|
-
} else if (key === NAME_KEY && _obj[key] !==
|
|
3482
|
+
} else if (key === NAME_KEY && _obj[key] !== '') {
|
|
3387
3483
|
paths.forEach(function (path) {
|
|
3388
3484
|
var formValue = get(formData, path);
|
|
3389
3485
|
// adds path to fieldNames if it points to a value
|
|
3390
3486
|
// or an empty object/array
|
|
3391
|
-
if (typeof formValue !==
|
|
3487
|
+
if (typeof formValue !== 'object' || isEmpty(formValue)) {
|
|
3392
3488
|
acc.push(path);
|
|
3393
3489
|
}
|
|
3394
3490
|
});
|
|
@@ -3421,7 +3517,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3421
3517
|
var newFormData = formData;
|
|
3422
3518
|
if (omitExtraData === true && liveOmit === true) {
|
|
3423
3519
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3424
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3520
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
3425
3521
|
var fieldNames = _this.getFieldNames(pathSchema, formData);
|
|
3426
3522
|
newFormData = _this.getUsedFormData(formData, fieldNames);
|
|
3427
3523
|
state = {
|
|
@@ -3447,7 +3543,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3447
3543
|
schemaValidationErrorSchema: schemaValidationErrorSchema
|
|
3448
3544
|
};
|
|
3449
3545
|
} else if (!noValidate && newErrorSchema) {
|
|
3450
|
-
var _errorSchema = extraErrors ? mergeObjects(newErrorSchema, extraErrors,
|
|
3546
|
+
var _errorSchema = extraErrors ? mergeObjects(newErrorSchema, extraErrors, 'preventDuplicates') : newErrorSchema;
|
|
3451
3547
|
state = {
|
|
3452
3548
|
formData: newFormData,
|
|
3453
3549
|
errorSchema: _errorSchema,
|
|
@@ -3487,7 +3583,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3487
3583
|
schemaUtils = _this$state2.schemaUtils;
|
|
3488
3584
|
if (omitExtraData === true) {
|
|
3489
3585
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, newFormData);
|
|
3490
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3586
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', newFormData);
|
|
3491
3587
|
var fieldNames = _this.getFieldNames(pathSchema, newFormData);
|
|
3492
3588
|
newFormData = _this.getUsedFormData(newFormData, fieldNames);
|
|
3493
3589
|
}
|
|
@@ -3506,20 +3602,20 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3506
3602
|
if (onSubmit) {
|
|
3507
3603
|
onSubmit(_extends({}, _this.state, {
|
|
3508
3604
|
formData: newFormData,
|
|
3509
|
-
status:
|
|
3605
|
+
status: 'submitted'
|
|
3510
3606
|
}), event);
|
|
3511
3607
|
}
|
|
3512
3608
|
});
|
|
3513
3609
|
}
|
|
3514
3610
|
};
|
|
3515
3611
|
if (!props.validator) {
|
|
3516
|
-
throw new Error(
|
|
3612
|
+
throw new Error('A validator is required for Form functionality to work');
|
|
3517
3613
|
}
|
|
3518
3614
|
_this.state = _this.getStateFromProps(props, props.formData);
|
|
3519
3615
|
if (_this.props.onChange && !deepEquals(_this.state.formData, _this.props.formData)) {
|
|
3520
3616
|
_this.props.onChange(_this.state);
|
|
3521
3617
|
}
|
|
3522
|
-
_this.formElement = /*#__PURE__*/
|
|
3618
|
+
_this.formElement = /*#__PURE__*/createRef();
|
|
3523
3619
|
return _this;
|
|
3524
3620
|
}
|
|
3525
3621
|
/** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
|
|
@@ -3546,10 +3642,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3546
3642
|
*/;
|
|
3547
3643
|
_proto.getStateFromProps = function getStateFromProps(props, inputFormData) {
|
|
3548
3644
|
var state = this.state || {};
|
|
3549
|
-
var schema =
|
|
3550
|
-
var uiSchema = (
|
|
3551
|
-
var edit = typeof inputFormData !==
|
|
3552
|
-
var liveValidate =
|
|
3645
|
+
var schema = 'schema' in props ? props.schema : this.props.schema;
|
|
3646
|
+
var uiSchema = ('uiSchema' in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
3647
|
+
var edit = typeof inputFormData !== 'undefined';
|
|
3648
|
+
var liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
3553
3649
|
var mustValidate = edit && !props.noValidate && liveValidate;
|
|
3554
3650
|
var rootSchema = schema;
|
|
3555
3651
|
var schemaUtils = state.schemaUtils;
|
|
@@ -3598,7 +3694,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3598
3694
|
errorSchema = merged.errorSchema;
|
|
3599
3695
|
errors = merged.errors;
|
|
3600
3696
|
}
|
|
3601
|
-
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema[
|
|
3697
|
+
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema['ui:rootFieldId'], formData, props.idPrefix, props.idSeparator);
|
|
3602
3698
|
var nextState = {
|
|
3603
3699
|
schemaUtils: schemaUtils,
|
|
3604
3700
|
schema: schema,
|
|
@@ -3650,9 +3746,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3650
3746
|
uiSchema = _this$state3.uiSchema;
|
|
3651
3747
|
var formContext = this.props.formContext;
|
|
3652
3748
|
var options = getUiOptions(uiSchema);
|
|
3653
|
-
var ErrorListTemplate = getTemplate(
|
|
3749
|
+
var ErrorListTemplate = getTemplate('ErrorListTemplate', registry, options);
|
|
3654
3750
|
if (errors && errors.length) {
|
|
3655
|
-
return
|
|
3751
|
+
return jsx(ErrorListTemplate, {
|
|
3656
3752
|
errors: errors,
|
|
3657
3753
|
errorSchema: errorSchema || {},
|
|
3658
3754
|
schema: schema,
|
|
@@ -3694,7 +3790,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3694
3790
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
3695
3791
|
_proto.submit = function submit() {
|
|
3696
3792
|
if (this.formElement.current) {
|
|
3697
|
-
this.formElement.current.dispatchEvent(new CustomEvent(
|
|
3793
|
+
this.formElement.current.dispatchEvent(new CustomEvent('submit', {
|
|
3698
3794
|
cancelable: true
|
|
3699
3795
|
}));
|
|
3700
3796
|
this.formElement.current.requestSubmit();
|
|
@@ -3709,12 +3805,12 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3709
3805
|
_proto.focusOnError = function focusOnError(error) {
|
|
3710
3806
|
var _this$props4 = this.props,
|
|
3711
3807
|
_this$props4$idPrefix = _this$props4.idPrefix,
|
|
3712
|
-
idPrefix = _this$props4$idPrefix === void 0 ?
|
|
3808
|
+
idPrefix = _this$props4$idPrefix === void 0 ? 'root' : _this$props4$idPrefix,
|
|
3713
3809
|
_this$props4$idSepara = _this$props4.idSeparator,
|
|
3714
|
-
idSeparator = _this$props4$idSepara === void 0 ?
|
|
3810
|
+
idSeparator = _this$props4$idSepara === void 0 ? '_' : _this$props4$idSepara;
|
|
3715
3811
|
var property = error.property;
|
|
3716
3812
|
var path = _toPath(property);
|
|
3717
|
-
if (path[0] ===
|
|
3813
|
+
if (path[0] === '') {
|
|
3718
3814
|
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3719
3815
|
path[0] = idPrefix;
|
|
3720
3816
|
} else {
|
|
@@ -3766,7 +3862,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3766
3862
|
if (onError) {
|
|
3767
3863
|
onError(errors);
|
|
3768
3864
|
} else {
|
|
3769
|
-
console.error(
|
|
3865
|
+
console.error('Form validation failed', errors);
|
|
3770
3866
|
}
|
|
3771
3867
|
});
|
|
3772
3868
|
return false;
|
|
@@ -3783,7 +3879,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3783
3879
|
idPrefix = _this$props6.idPrefix,
|
|
3784
3880
|
idSeparator = _this$props6.idSeparator,
|
|
3785
3881
|
_this$props6$classNam = _this$props6.className,
|
|
3786
|
-
className = _this$props6$classNam === void 0 ?
|
|
3882
|
+
className = _this$props6$classNam === void 0 ? '' : _this$props6$classNam,
|
|
3787
3883
|
tagName = _this$props6.tagName,
|
|
3788
3884
|
name = _this$props6.name,
|
|
3789
3885
|
method = _this$props6.method,
|
|
@@ -3800,7 +3896,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3800
3896
|
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
3801
3897
|
formContext = _this$props6.formContext,
|
|
3802
3898
|
_this$props6$showErro = _this$props6.showErrorList,
|
|
3803
|
-
showErrorList = _this$props6$showErro === void 0 ?
|
|
3899
|
+
showErrorList = _this$props6$showErro === void 0 ? 'top' : _this$props6$showErro,
|
|
3804
3900
|
_internalFormWrapper = _this$props6._internalFormWrapper;
|
|
3805
3901
|
var _this$state4 = this.state,
|
|
3806
3902
|
schema = _this$state4.schema,
|
|
@@ -3815,9 +3911,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3815
3911
|
// PropTypes.elementType to use for the inner tag, so we'll need to pass `tagName` along if it is provided.
|
|
3816
3912
|
// NOTE, the `as` prop is native to `semantic-ui` and is emulated in the `material-ui` theme
|
|
3817
3913
|
var as = _internalFormWrapper ? tagName : undefined;
|
|
3818
|
-
var FormTag = _internalFormWrapper || tagName ||
|
|
3819
|
-
return
|
|
3820
|
-
className: className ? className :
|
|
3914
|
+
var FormTag = _internalFormWrapper || tagName || 'form';
|
|
3915
|
+
return jsxs(FormTag, {
|
|
3916
|
+
className: className ? className : 'rjsf',
|
|
3821
3917
|
id: id,
|
|
3822
3918
|
name: name,
|
|
3823
3919
|
method: method,
|
|
@@ -3829,27 +3925,28 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3829
3925
|
noValidate: noHtml5Validate,
|
|
3830
3926
|
onSubmit: this.onSubmit,
|
|
3831
3927
|
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
|
-
|
|
3928
|
+
ref: this.formElement,
|
|
3929
|
+
children: [showErrorList === 'top' && this.renderErrors(registry), jsx(_SchemaField, {
|
|
3930
|
+
name: '',
|
|
3931
|
+
schema: schema,
|
|
3932
|
+
uiSchema: uiSchema,
|
|
3933
|
+
errorSchema: errorSchema,
|
|
3934
|
+
idSchema: idSchema,
|
|
3935
|
+
idPrefix: idPrefix,
|
|
3936
|
+
idSeparator: idSeparator,
|
|
3937
|
+
formContext: formContext,
|
|
3938
|
+
formData: formData,
|
|
3939
|
+
onChange: this.onChange,
|
|
3940
|
+
onBlur: this.onBlur,
|
|
3941
|
+
onFocus: this.onFocus,
|
|
3942
|
+
registry: registry,
|
|
3943
|
+
disabled: disabled,
|
|
3944
|
+
readonly: readonly
|
|
3945
|
+
}), children ? children : jsx(SubmitButton, {
|
|
3946
|
+
uiSchema: uiSchema,
|
|
3947
|
+
registry: registry
|
|
3948
|
+
}), showErrorList === 'bottom' && this.renderErrors(registry)]
|
|
3949
|
+
});
|
|
3853
3950
|
};
|
|
3854
3951
|
return Form;
|
|
3855
3952
|
}(Component);
|
|
@@ -3868,7 +3965,7 @@ function withTheme(themeProps) {
|
|
|
3868
3965
|
templates = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.templates, templates, {
|
|
3869
3966
|
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
3967
|
});
|
|
3871
|
-
return
|
|
3968
|
+
return jsx(Form, _extends({}, themeProps, directProps, {
|
|
3872
3969
|
fields: fields,
|
|
3873
3970
|
widgets: widgets,
|
|
3874
3971
|
templates: templates,
|