@rjsf/core 5.1.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 +898 -763
- 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 +865 -730
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +899 -766
- 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 +23 -17
- package/package.json +6 -5
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
6
7
|
var utils = require('@rjsf/utils');
|
|
7
8
|
var get = require('lodash/get');
|
|
8
9
|
var isEmpty = require('lodash/isEmpty');
|
|
@@ -14,10 +15,10 @@ var nanoid = require('nanoid');
|
|
|
14
15
|
var omit = require('lodash/omit');
|
|
15
16
|
var has = require('lodash/has');
|
|
16
17
|
var unset = require('lodash/unset');
|
|
18
|
+
var Markdown = require('markdown-to-jsx');
|
|
17
19
|
|
|
18
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
21
|
|
|
20
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
22
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
22
23
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
23
24
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
@@ -27,6 +28,7 @@ var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
|
27
28
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
28
29
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
29
30
|
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
31
|
+
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
30
32
|
|
|
31
33
|
function _defineProperties(target, props) {
|
|
32
34
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -206,7 +208,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
206
208
|
onChange = _this$props3.onChange,
|
|
207
209
|
errorSchema = _this$props3.errorSchema;
|
|
208
210
|
var newErrorSchema;
|
|
209
|
-
if (
|
|
211
|
+
if (errorSchema) {
|
|
210
212
|
newErrorSchema = {};
|
|
211
213
|
for (var idx in errorSchema) {
|
|
212
214
|
var i = parseInt(idx);
|
|
@@ -247,7 +249,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
247
249
|
var newFormData = arrayData.map(function (item, i) {
|
|
248
250
|
// We need to treat undefined items as nulls to have validation.
|
|
249
251
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
250
|
-
var jsonValue = typeof value ===
|
|
252
|
+
var jsonValue = typeof value === 'undefined' ? null : value;
|
|
251
253
|
return index === i ? jsonValue : item;
|
|
252
254
|
});
|
|
253
255
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends2 = {}, _extends2[index] = newErrorSchema, _extends2)), id);
|
|
@@ -307,10 +309,10 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
307
309
|
if (Array.isArray(itemSchema.type)) {
|
|
308
310
|
// While we don't yet support composite/nullable jsonschema types, it's
|
|
309
311
|
// future-proof to check for requirement against these.
|
|
310
|
-
return !itemSchema.type.includes(
|
|
312
|
+
return !itemSchema.type.includes('null');
|
|
311
313
|
}
|
|
312
314
|
// All non-null array item types are inherently required by design
|
|
313
|
-
return itemSchema.type !==
|
|
315
|
+
return itemSchema.type !== 'null';
|
|
314
316
|
}
|
|
315
317
|
/** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
|
|
316
318
|
* then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
|
|
@@ -383,14 +385,15 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
383
385
|
uiSchema = _this$props7.uiSchema,
|
|
384
386
|
idSchema = _this$props7.idSchema,
|
|
385
387
|
registry = _this$props7.registry;
|
|
386
|
-
var schemaUtils = registry.schemaUtils
|
|
388
|
+
var schemaUtils = registry.schemaUtils,
|
|
389
|
+
translateString = registry.translateString;
|
|
387
390
|
if (!(utils.ITEMS_KEY in schema)) {
|
|
388
391
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
389
|
-
var UnsupportedFieldTemplate = utils.getTemplate(
|
|
390
|
-
return
|
|
392
|
+
var UnsupportedFieldTemplate = utils.getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
393
|
+
return jsxRuntime.jsx(UnsupportedFieldTemplate, {
|
|
391
394
|
schema: schema,
|
|
392
395
|
idSchema: idSchema,
|
|
393
|
-
reason:
|
|
396
|
+
reason: translateString(utils.TranslatableString.MissingItems),
|
|
394
397
|
registry: registry
|
|
395
398
|
});
|
|
396
399
|
}
|
|
@@ -433,7 +436,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
433
436
|
onFocus = _this$props8.onFocus,
|
|
434
437
|
idPrefix = _this$props8.idPrefix,
|
|
435
438
|
_this$props8$idSepara = _this$props8.idSeparator,
|
|
436
|
-
idSeparator = _this$props8$idSepara === void 0 ?
|
|
439
|
+
idSeparator = _this$props8$idSepara === void 0 ? '_' : _this$props8$idSepara,
|
|
437
440
|
rawErrors = _this$props8.rawErrors;
|
|
438
441
|
var keyedFormData = this.state.keyedFormData;
|
|
439
442
|
var title = schema.title === undefined ? name : schema.title;
|
|
@@ -488,8 +491,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
488
491
|
rawErrors: rawErrors,
|
|
489
492
|
registry: registry
|
|
490
493
|
};
|
|
491
|
-
var Template = utils.getTemplate(
|
|
492
|
-
return
|
|
494
|
+
var Template = utils.getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
495
|
+
return jsxRuntime.jsx(Template, _extends({}, arrayProps));
|
|
493
496
|
}
|
|
494
497
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
495
498
|
*/;
|
|
@@ -522,8 +525,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
522
525
|
widget = _getUiOptions2.widget,
|
|
523
526
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
524
527
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
525
|
-
return
|
|
528
|
+
return jsxRuntime.jsx(Widget, {
|
|
526
529
|
id: idSchema.$id,
|
|
530
|
+
name: name,
|
|
527
531
|
multiple: true,
|
|
528
532
|
onChange: this.onSelectChange,
|
|
529
533
|
onBlur: onBlur,
|
|
@@ -575,11 +579,12 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
575
579
|
var enumOptions = utils.optionsList(itemsSchema);
|
|
576
580
|
var _getUiOptions3 = utils.getUiOptions(uiSchema),
|
|
577
581
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
578
|
-
widget = _getUiOptions3$widget === void 0 ?
|
|
582
|
+
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
579
583
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
580
584
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
581
|
-
return
|
|
585
|
+
return jsxRuntime.jsx(Widget, {
|
|
582
586
|
id: idSchema.$id,
|
|
587
|
+
name: name,
|
|
583
588
|
multiple: true,
|
|
584
589
|
onChange: this.onSelectChange,
|
|
585
590
|
onBlur: onBlur,
|
|
@@ -628,12 +633,13 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
628
633
|
formContext = registry.formContext;
|
|
629
634
|
var _getUiOptions4 = utils.getUiOptions(uiSchema),
|
|
630
635
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
631
|
-
widget = _getUiOptions4$widget === void 0 ?
|
|
636
|
+
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
632
637
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
633
638
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
634
|
-
return
|
|
639
|
+
return jsxRuntime.jsx(Widget, {
|
|
635
640
|
options: options,
|
|
636
641
|
id: idSchema.$id,
|
|
642
|
+
name: name,
|
|
637
643
|
multiple: true,
|
|
638
644
|
onChange: this.onSelectChange,
|
|
639
645
|
onBlur: onBlur,
|
|
@@ -649,7 +655,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
649
655
|
formContext: formContext,
|
|
650
656
|
autofocus: autofocus,
|
|
651
657
|
rawErrors: rawErrors,
|
|
652
|
-
label:
|
|
658
|
+
label: ''
|
|
653
659
|
});
|
|
654
660
|
}
|
|
655
661
|
/** Renders an array that has a maximum limit of items
|
|
@@ -665,7 +671,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
665
671
|
errorSchema = _this$props12.errorSchema,
|
|
666
672
|
idPrefix = _this$props12.idPrefix,
|
|
667
673
|
_this$props12$idSepar = _this$props12.idSeparator,
|
|
668
|
-
idSeparator = _this$props12$idSepar === void 0 ?
|
|
674
|
+
idSeparator = _this$props12$idSepar === void 0 ? '_' : _this$props12$idSepar,
|
|
669
675
|
idSchema = _this$props12.idSchema,
|
|
670
676
|
name = _this$props12.name,
|
|
671
677
|
_this$props12$disable = _this$props12.disabled,
|
|
@@ -701,7 +707,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
701
707
|
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
702
708
|
var arrayProps = {
|
|
703
709
|
canAdd: canAdd,
|
|
704
|
-
className:
|
|
710
|
+
className: 'field field-array field-array-fixed-items',
|
|
705
711
|
disabled: disabled,
|
|
706
712
|
idSchema: idSchema,
|
|
707
713
|
formData: formData,
|
|
@@ -746,8 +752,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
746
752
|
formContext: formContext,
|
|
747
753
|
rawErrors: rawErrors
|
|
748
754
|
};
|
|
749
|
-
var Template = utils.getTemplate(
|
|
750
|
-
return
|
|
755
|
+
var Template = utils.getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
756
|
+
return jsxRuntime.jsx(Template, _extends({}, arrayProps));
|
|
751
757
|
}
|
|
752
758
|
/** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
|
|
753
759
|
* back to the `ArrayFieldItemTemplate`.
|
|
@@ -803,7 +809,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
803
809
|
return has[key];
|
|
804
810
|
});
|
|
805
811
|
return {
|
|
806
|
-
children:
|
|
812
|
+
children: jsxRuntime.jsx(ItemSchemaField, {
|
|
807
813
|
name: name,
|
|
808
814
|
index: index,
|
|
809
815
|
schema: itemSchema,
|
|
@@ -825,7 +831,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
825
831
|
autofocus: autofocus,
|
|
826
832
|
rawErrors: rawErrors
|
|
827
833
|
}),
|
|
828
|
-
className:
|
|
834
|
+
className: 'array-item',
|
|
829
835
|
disabled: disabled,
|
|
830
836
|
canAdd: canAdd,
|
|
831
837
|
hasToolbar: has.toolbar,
|
|
@@ -847,12 +853,15 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
847
853
|
_createClass(ArrayField, [{
|
|
848
854
|
key: "itemTitle",
|
|
849
855
|
get: function get() {
|
|
850
|
-
var
|
|
851
|
-
|
|
856
|
+
var _this$props14 = this.props,
|
|
857
|
+
schema = _this$props14.schema,
|
|
858
|
+
registry = _this$props14.registry;
|
|
859
|
+
var translateString = registry.translateString;
|
|
860
|
+
return get__default["default"](schema, [utils.ITEMS_KEY, 'title'], get__default["default"](schema, [utils.ITEMS_KEY, 'description'], translateString(utils.TranslatableString.ArrayItemTitle)));
|
|
852
861
|
}
|
|
853
862
|
}]);
|
|
854
863
|
return ArrayField;
|
|
855
|
-
}(
|
|
864
|
+
}(react.Component);
|
|
856
865
|
|
|
857
866
|
var _excluded$8 = ["widget"];
|
|
858
867
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
@@ -877,19 +886,22 @@ function BooleanField(props) {
|
|
|
877
886
|
rawErrors = props.rawErrors;
|
|
878
887
|
var title = schema.title;
|
|
879
888
|
var widgets = registry.widgets,
|
|
880
|
-
formContext = registry.formContext
|
|
889
|
+
formContext = registry.formContext,
|
|
890
|
+
translateString = registry.translateString;
|
|
881
891
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
882
892
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
883
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
893
|
+
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
884
894
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
885
895
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
896
|
+
var yes = translateString(utils.TranslatableString.YesLabel);
|
|
897
|
+
var no = translateString(utils.TranslatableString.NoLabel);
|
|
886
898
|
var enumOptions;
|
|
887
899
|
if (Array.isArray(schema.oneOf)) {
|
|
888
900
|
enumOptions = utils.optionsList({
|
|
889
901
|
oneOf: schema.oneOf.map(function (option) {
|
|
890
902
|
if (isObject__default["default"](option)) {
|
|
891
903
|
return _extends({}, option, {
|
|
892
|
-
title: option.title || (option["const"] === true ?
|
|
904
|
+
title: option.title || (option["const"] === true ? yes : no)
|
|
893
905
|
});
|
|
894
906
|
}
|
|
895
907
|
return undefined;
|
|
@@ -903,14 +915,14 @@ function BooleanField(props) {
|
|
|
903
915
|
var schemaWithEnumNames = schema;
|
|
904
916
|
var enums = (_schema$enum = schema["enum"]) != null ? _schema$enum : [true, false];
|
|
905
917
|
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every(function (v) {
|
|
906
|
-
return typeof v ===
|
|
918
|
+
return typeof v === 'boolean';
|
|
907
919
|
})) {
|
|
908
920
|
enumOptions = [{
|
|
909
921
|
value: enums[0],
|
|
910
|
-
label: enums[0] ?
|
|
922
|
+
label: enums[0] ? yes : no
|
|
911
923
|
}, {
|
|
912
924
|
value: enums[1],
|
|
913
|
-
label: enums[1] ?
|
|
925
|
+
label: enums[1] ? yes : no
|
|
914
926
|
}];
|
|
915
927
|
} else {
|
|
916
928
|
enumOptions = utils.optionsList({
|
|
@@ -920,13 +932,14 @@ function BooleanField(props) {
|
|
|
920
932
|
});
|
|
921
933
|
}
|
|
922
934
|
}
|
|
923
|
-
return
|
|
935
|
+
return jsxRuntime.jsx(Widget, {
|
|
924
936
|
options: _extends({}, options, {
|
|
925
937
|
enumOptions: enumOptions
|
|
926
938
|
}),
|
|
927
939
|
schema: schema,
|
|
928
940
|
uiSchema: uiSchema,
|
|
929
941
|
id: idSchema.$id,
|
|
942
|
+
name: name,
|
|
930
943
|
onChange: onChange,
|
|
931
944
|
onFocus: onFocus,
|
|
932
945
|
onBlur: onBlur,
|
|
@@ -943,9 +956,6 @@ function BooleanField(props) {
|
|
|
943
956
|
}
|
|
944
957
|
|
|
945
958
|
var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"];
|
|
946
|
-
/** The prefix used when a oneOf option does not have a title
|
|
947
|
-
*/
|
|
948
|
-
var UNKNOWN_OPTION_PREFIX = "Option";
|
|
949
959
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
950
960
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
951
961
|
*
|
|
@@ -979,7 +989,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
979
989
|
if (newFormData && newOption) {
|
|
980
990
|
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
981
991
|
// so that only the root objects themselves are created without adding undefined children properties
|
|
982
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData,
|
|
992
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
983
993
|
}
|
|
984
994
|
onChange(newFormData, undefined, _this.getFieldId());
|
|
985
995
|
_this.setState({
|
|
@@ -1066,12 +1076,13 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1066
1076
|
var _this$props4 = this.props,
|
|
1067
1077
|
idSchema = _this$props4.idSchema,
|
|
1068
1078
|
schema = _this$props4.schema;
|
|
1069
|
-
return "" + idSchema.$id + (schema.oneOf ?
|
|
1079
|
+
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1070
1080
|
}
|
|
1071
1081
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1072
1082
|
*/;
|
|
1073
1083
|
_proto.render = function render() {
|
|
1074
1084
|
var _this$props5 = this.props,
|
|
1085
|
+
name = _this$props5.name,
|
|
1075
1086
|
baseType = _this$props5.baseType,
|
|
1076
1087
|
_this$props5$disabled = _this$props5.disabled,
|
|
1077
1088
|
disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
|
|
@@ -1084,14 +1095,15 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1084
1095
|
schema = _this$props5.schema,
|
|
1085
1096
|
uiSchema = _this$props5.uiSchema;
|
|
1086
1097
|
var widgets = registry.widgets,
|
|
1087
|
-
fields = registry.fields
|
|
1098
|
+
fields = registry.fields,
|
|
1099
|
+
translateString = registry.translateString;
|
|
1088
1100
|
var _SchemaField = fields.SchemaField;
|
|
1089
1101
|
var _this$state2 = this.state,
|
|
1090
1102
|
selectedOption = _this$state2.selectedOption,
|
|
1091
1103
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1092
1104
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1093
1105
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1094
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
1106
|
+
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1095
1107
|
placeholder = _getUiOptions.placeholder,
|
|
1096
1108
|
autofocus = _getUiOptions.autofocus,
|
|
1097
1109
|
autocomplete = _getUiOptions.autocomplete,
|
|
@@ -1099,7 +1111,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1099
1111
|
title = _getUiOptions$title === void 0 ? schema.title : _getUiOptions$title,
|
|
1100
1112
|
uiOptions = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$7);
|
|
1101
1113
|
var Widget = utils.getWidget({
|
|
1102
|
-
type:
|
|
1114
|
+
type: 'number'
|
|
1103
1115
|
}, widget, widgets);
|
|
1104
1116
|
var rawErrors = get__default["default"](errorSchema, utils.ERRORS_KEY, []);
|
|
1105
1117
|
var fieldErrorSchema = omit__default["default"](errorSchema, [utils.ERRORS_KEY]);
|
|
@@ -1112,46 +1124,50 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1112
1124
|
type: baseType
|
|
1113
1125
|
});
|
|
1114
1126
|
}
|
|
1115
|
-
var
|
|
1127
|
+
var translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
|
|
1128
|
+
var translateParams = title ? [title] : [];
|
|
1116
1129
|
var enumOptions = retrievedOptions.map(function (opt, index) {
|
|
1117
1130
|
return {
|
|
1118
|
-
label: opt.title ||
|
|
1131
|
+
label: opt.title || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1119
1132
|
value: index
|
|
1120
1133
|
};
|
|
1121
1134
|
});
|
|
1122
|
-
return
|
|
1123
|
-
className:
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1135
|
+
return jsxRuntime.jsxs("div", {
|
|
1136
|
+
className: 'panel panel-default panel-body',
|
|
1137
|
+
children: [jsxRuntime.jsx("div", {
|
|
1138
|
+
className: 'form-group',
|
|
1139
|
+
children: jsxRuntime.jsx(Widget, {
|
|
1140
|
+
id: this.getFieldId(),
|
|
1141
|
+
name: "" + name + (schema.oneOf ? '__oneof_select' : '__anyof_select'),
|
|
1142
|
+
schema: {
|
|
1143
|
+
type: 'number',
|
|
1144
|
+
"default": 0
|
|
1145
|
+
},
|
|
1146
|
+
onChange: this.onOptionChange,
|
|
1147
|
+
onBlur: onBlur,
|
|
1148
|
+
onFocus: onFocus,
|
|
1149
|
+
disabled: disabled || isEmpty__default["default"](enumOptions),
|
|
1150
|
+
multiple: false,
|
|
1151
|
+
rawErrors: rawErrors,
|
|
1152
|
+
errorSchema: fieldErrorSchema,
|
|
1153
|
+
value: selectedOption >= 0 ? selectedOption : undefined,
|
|
1154
|
+
options: _extends({
|
|
1155
|
+
enumOptions: enumOptions
|
|
1156
|
+
}, uiOptions),
|
|
1157
|
+
registry: registry,
|
|
1158
|
+
formContext: formContext,
|
|
1159
|
+
placeholder: placeholder,
|
|
1160
|
+
autocomplete: autocomplete,
|
|
1161
|
+
autofocus: autofocus,
|
|
1162
|
+
label: ''
|
|
1163
|
+
})
|
|
1164
|
+
}), option !== null && jsxRuntime.jsx(_SchemaField, _extends({}, this.props, {
|
|
1165
|
+
schema: optionSchema
|
|
1166
|
+
}))]
|
|
1167
|
+
});
|
|
1152
1168
|
};
|
|
1153
1169
|
return AnyOfField;
|
|
1154
|
-
}(
|
|
1170
|
+
}(react.Component);
|
|
1155
1171
|
|
|
1156
1172
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
1157
1173
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
@@ -1185,7 +1201,7 @@ function NumberField(props) {
|
|
|
1185
1201
|
onChange = props.onChange,
|
|
1186
1202
|
formData = props.formData,
|
|
1187
1203
|
initialValue = props.value;
|
|
1188
|
-
var _useState =
|
|
1204
|
+
var _useState = react.useState(initialValue),
|
|
1189
1205
|
lastValue = _useState[0],
|
|
1190
1206
|
setLastValue = _useState[1];
|
|
1191
1207
|
var StringField = registry.fields.StringField;
|
|
@@ -1194,32 +1210,32 @@ function NumberField(props) {
|
|
|
1194
1210
|
*
|
|
1195
1211
|
* @param value - The current value for the change occurring
|
|
1196
1212
|
*/
|
|
1197
|
-
var handleChange =
|
|
1213
|
+
var handleChange = react.useCallback(function (value) {
|
|
1198
1214
|
// Cache the original value in component state
|
|
1199
1215
|
setLastValue(value);
|
|
1200
1216
|
// Normalize decimals that don't start with a zero character in advance so
|
|
1201
1217
|
// that the rest of the normalization logic is simpler
|
|
1202
|
-
if (("" + value).charAt(0) ===
|
|
1218
|
+
if (("" + value).charAt(0) === '.') {
|
|
1203
1219
|
value = "0" + value;
|
|
1204
1220
|
}
|
|
1205
1221
|
// Check that the value is a string (this can happen if the widget used is a
|
|
1206
1222
|
// <select>, due to an enum declaration etc) then, if the value ends in a
|
|
1207
1223
|
// trailing decimal point or multiple zeroes, strip the trailing values
|
|
1208
|
-
var processed = typeof value ===
|
|
1224
|
+
var processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix) ? utils.asNumber(value.replace(trailingCharMatcher, '')) : utils.asNumber(value);
|
|
1209
1225
|
onChange(processed);
|
|
1210
1226
|
}, [onChange]);
|
|
1211
|
-
if (typeof lastValue ===
|
|
1227
|
+
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
1212
1228
|
// Construct a regular expression that checks for a string that consists
|
|
1213
1229
|
// of the formData value suffixed with zero or one '.' characters and zero
|
|
1214
1230
|
// or more '0' characters
|
|
1215
|
-
var re = new RegExp(("" + value).replace(
|
|
1231
|
+
var re = new RegExp(("" + value).replace('.', '\\.') + '\\.?0*$');
|
|
1216
1232
|
// If the cached "lastValue" is a match, use that instead of the formData
|
|
1217
1233
|
// value to prevent the input value from changing in the UI
|
|
1218
1234
|
if (lastValue.match(re)) {
|
|
1219
1235
|
value = lastValue;
|
|
1220
1236
|
}
|
|
1221
1237
|
}
|
|
1222
|
-
return
|
|
1238
|
+
return jsxRuntime.jsx(StringField, _extends({}, props, {
|
|
1223
1239
|
formData: value,
|
|
1224
1240
|
onChange: handleChange
|
|
1225
1241
|
}));
|
|
@@ -1260,7 +1276,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1260
1276
|
// fields which are "mandated" by the schema, these fields can
|
|
1261
1277
|
// be set to undefined by clicking a "delete field" button, so
|
|
1262
1278
|
// set empty values to the empty string.
|
|
1263
|
-
value =
|
|
1279
|
+
value = '';
|
|
1264
1280
|
}
|
|
1265
1281
|
var newFormData = _extends({}, formData, (_extends2 = {}, _extends2[name] = value, _extends2));
|
|
1266
1282
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends3 = {}, _extends3[name] = newErrorSchema, _extends3)), id);
|
|
@@ -1281,7 +1297,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1281
1297
|
var uiSchema = _this.props.uiSchema;
|
|
1282
1298
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1283
1299
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1284
|
-
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ?
|
|
1300
|
+
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1285
1301
|
var index = 0;
|
|
1286
1302
|
var newKey = preferredKey;
|
|
1287
1303
|
while (has__default["default"](formData, newKey)) {
|
|
@@ -1336,10 +1352,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1336
1352
|
type = apSchema.type;
|
|
1337
1353
|
}
|
|
1338
1354
|
if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
|
|
1339
|
-
type =
|
|
1355
|
+
type = 'object';
|
|
1340
1356
|
}
|
|
1341
1357
|
}
|
|
1342
|
-
var newKey = _this.getAvailableKey(
|
|
1358
|
+
var newKey = _this.getAvailableKey('newKey', newFormData);
|
|
1343
1359
|
// Cast this to make the `set` work properly
|
|
1344
1360
|
set__default["default"](newFormData, newKey, _this.getDefaultValue(type));
|
|
1345
1361
|
onChange(newFormData);
|
|
@@ -1370,22 +1386,22 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1370
1386
|
* @param type - The type of the new additional schema property
|
|
1371
1387
|
*/
|
|
1372
1388
|
_proto.getDefaultValue = function getDefaultValue(type) {
|
|
1389
|
+
var translateString = this.props.registry.translateString;
|
|
1373
1390
|
switch (type) {
|
|
1374
|
-
case
|
|
1375
|
-
return "New Value";
|
|
1376
|
-
case "array":
|
|
1391
|
+
case 'array':
|
|
1377
1392
|
return [];
|
|
1378
|
-
case
|
|
1393
|
+
case 'boolean':
|
|
1379
1394
|
return false;
|
|
1380
|
-
case
|
|
1395
|
+
case 'null':
|
|
1381
1396
|
return null;
|
|
1382
|
-
case
|
|
1397
|
+
case 'number':
|
|
1383
1398
|
return 0;
|
|
1384
|
-
case
|
|
1399
|
+
case 'object':
|
|
1385
1400
|
return {};
|
|
1401
|
+
case 'string':
|
|
1386
1402
|
default:
|
|
1387
1403
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1388
|
-
return
|
|
1404
|
+
return translateString(utils.TranslatableString.NewStringDefault);
|
|
1389
1405
|
}
|
|
1390
1406
|
}
|
|
1391
1407
|
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
@@ -1432,25 +1448,31 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1432
1448
|
var properties = Object.keys(schemaProperties);
|
|
1433
1449
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1434
1450
|
} catch (err) {
|
|
1435
|
-
return
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1451
|
+
return jsxRuntime.jsxs("div", {
|
|
1452
|
+
children: [jsxRuntime.jsxs("p", {
|
|
1453
|
+
className: 'config-error',
|
|
1454
|
+
style: {
|
|
1455
|
+
color: 'red'
|
|
1456
|
+
},
|
|
1457
|
+
children: ["Invalid ", name || 'root', " object field configuration:", jsxRuntime.jsx("em", {
|
|
1458
|
+
children: err.message
|
|
1459
|
+
}), "."]
|
|
1460
|
+
}), jsxRuntime.jsx("pre", {
|
|
1461
|
+
children: JSON.stringify(schema)
|
|
1462
|
+
})]
|
|
1463
|
+
});
|
|
1441
1464
|
}
|
|
1442
|
-
var Template = utils.getTemplate(
|
|
1465
|
+
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1443
1466
|
var templateProps = {
|
|
1444
1467
|
title: uiOptions.title || title,
|
|
1445
1468
|
description: description,
|
|
1446
1469
|
properties: orderedProperties.map(function (name) {
|
|
1447
1470
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
1448
1471
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
1449
|
-
var hidden = utils.getUiOptions(fieldUiSchema).widget ===
|
|
1472
|
+
var hidden = utils.getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
1450
1473
|
var fieldIdSchema = get__default["default"](idSchema, [name], {});
|
|
1451
1474
|
return {
|
|
1452
|
-
content:
|
|
1453
|
-
key: name,
|
|
1475
|
+
content: jsxRuntime.jsx(SchemaField, {
|
|
1454
1476
|
name: name,
|
|
1455
1477
|
required: _this2.isRequired(name),
|
|
1456
1478
|
schema: get__default["default"](schema, [utils.PROPERTIES_KEY, name], {}),
|
|
@@ -1471,7 +1493,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1471
1493
|
readonly: readonly,
|
|
1472
1494
|
hideError: hideError,
|
|
1473
1495
|
onDropPropertyClick: _this2.onDropPropertyClick
|
|
1474
|
-
}),
|
|
1496
|
+
}, name),
|
|
1475
1497
|
name: name,
|
|
1476
1498
|
readonly: readonly,
|
|
1477
1499
|
disabled: disabled,
|
|
@@ -1489,23 +1511,23 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1489
1511
|
formContext: formContext,
|
|
1490
1512
|
registry: registry
|
|
1491
1513
|
};
|
|
1492
|
-
return
|
|
1514
|
+
return jsxRuntime.jsx(Template, _extends({}, templateProps, {
|
|
1493
1515
|
onAddClick: this.handleAddClick
|
|
1494
1516
|
}));
|
|
1495
1517
|
};
|
|
1496
1518
|
return ObjectField;
|
|
1497
|
-
}(
|
|
1519
|
+
}(react.Component);
|
|
1498
1520
|
|
|
1499
1521
|
var _excluded$6 = ["__errors"];
|
|
1500
1522
|
/** The map of component type to FieldName */
|
|
1501
1523
|
var COMPONENT_TYPES = {
|
|
1502
|
-
array:
|
|
1503
|
-
"boolean":
|
|
1504
|
-
integer:
|
|
1505
|
-
number:
|
|
1506
|
-
object:
|
|
1507
|
-
string:
|
|
1508
|
-
"null":
|
|
1524
|
+
array: 'ArrayField',
|
|
1525
|
+
"boolean": 'BooleanField',
|
|
1526
|
+
integer: 'NumberField',
|
|
1527
|
+
number: 'NumberField',
|
|
1528
|
+
object: 'ObjectField',
|
|
1529
|
+
string: 'StringField',
|
|
1530
|
+
"null": 'NullField'
|
|
1509
1531
|
};
|
|
1510
1532
|
/** Computes and returns which `Field` implementation to return in order to render the field represented by the
|
|
1511
1533
|
* `schema`. The `uiOptions` are used to alter what potential `Field` implementation is actually returned. If no
|
|
@@ -1519,15 +1541,16 @@ var COMPONENT_TYPES = {
|
|
|
1519
1541
|
*/
|
|
1520
1542
|
function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
1521
1543
|
var field = uiOptions.field;
|
|
1522
|
-
var fields = registry.fields
|
|
1523
|
-
|
|
1544
|
+
var fields = registry.fields,
|
|
1545
|
+
translateString = registry.translateString;
|
|
1546
|
+
if (typeof field === 'function') {
|
|
1524
1547
|
return field;
|
|
1525
1548
|
}
|
|
1526
|
-
if (typeof field ===
|
|
1549
|
+
if (typeof field === 'string' && field in fields) {
|
|
1527
1550
|
return fields[field];
|
|
1528
1551
|
}
|
|
1529
1552
|
var schemaType = utils.getSchemaType(schema);
|
|
1530
|
-
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType ||
|
|
1553
|
+
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
|
|
1531
1554
|
var componentName = COMPONENT_TYPES[type];
|
|
1532
1555
|
// If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
|
|
1533
1556
|
// render a field and let the MultiSchemaField component handle the form display
|
|
@@ -1537,11 +1560,11 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1537
1560
|
};
|
|
1538
1561
|
}
|
|
1539
1562
|
return componentName in fields ? fields[componentName] : function () {
|
|
1540
|
-
var UnsupportedFieldTemplate = utils.getTemplate(
|
|
1541
|
-
return
|
|
1563
|
+
var UnsupportedFieldTemplate = utils.getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
1564
|
+
return jsxRuntime.jsx(UnsupportedFieldTemplate, {
|
|
1542
1565
|
schema: schema,
|
|
1543
1566
|
idSchema: idSchema,
|
|
1544
|
-
reason:
|
|
1567
|
+
reason: translateString(utils.TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
1545
1568
|
registry: registry
|
|
1546
1569
|
});
|
|
1547
1570
|
};
|
|
@@ -1571,17 +1594,17 @@ function SchemaFieldRender(props) {
|
|
|
1571
1594
|
var formContext = registry.formContext,
|
|
1572
1595
|
schemaUtils = registry.schemaUtils;
|
|
1573
1596
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1574
|
-
var FieldTemplate = utils.getTemplate(
|
|
1575
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
1576
|
-
var FieldHelpTemplate = utils.getTemplate(
|
|
1577
|
-
var FieldErrorTemplate = utils.getTemplate(
|
|
1597
|
+
var FieldTemplate = utils.getTemplate('FieldTemplate', registry, uiOptions);
|
|
1598
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1599
|
+
var FieldHelpTemplate = utils.getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
1600
|
+
var FieldErrorTemplate = utils.getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
1578
1601
|
var schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1579
1602
|
var fieldId = _idSchema[utils.ID_KEY];
|
|
1580
1603
|
var idSchema = utils.mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
1581
1604
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
1582
1605
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
1583
1606
|
*/
|
|
1584
|
-
var handleFieldComponentChange =
|
|
1607
|
+
var handleFieldComponentChange = react.useCallback(function (formData, newErrorSchema, id) {
|
|
1585
1608
|
var theId = id || fieldId;
|
|
1586
1609
|
return onChange(formData, newErrorSchema, theId);
|
|
1587
1610
|
}, [fieldId, onChange]);
|
|
@@ -1600,11 +1623,11 @@ function SchemaFieldRender(props) {
|
|
|
1600
1623
|
__errors = _ref.__errors,
|
|
1601
1624
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1602
1625
|
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1603
|
-
var fieldUiSchema = omit__default["default"](uiSchema, [
|
|
1626
|
+
var fieldUiSchema = omit__default["default"](uiSchema, ['ui:classNames', 'classNames', 'ui:style']);
|
|
1604
1627
|
if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1605
|
-
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], [
|
|
1628
|
+
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
1606
1629
|
}
|
|
1607
|
-
var field =
|
|
1630
|
+
var field = jsxRuntime.jsx(FieldComponent, _extends({}, props, {
|
|
1608
1631
|
onChange: handleFieldComponentChange,
|
|
1609
1632
|
idSchema: idSchema,
|
|
1610
1633
|
schema: schema,
|
|
@@ -1625,12 +1648,12 @@ function SchemaFieldRender(props) {
|
|
|
1625
1648
|
} else {
|
|
1626
1649
|
label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1627
1650
|
}
|
|
1628
|
-
var description = uiOptions.description || props.schema.description || schema.description ||
|
|
1651
|
+
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1629
1652
|
var help = uiOptions.help;
|
|
1630
|
-
var hidden = uiOptions.widget ===
|
|
1631
|
-
var classNames = [
|
|
1653
|
+
var hidden = uiOptions.widget === 'hidden';
|
|
1654
|
+
var classNames = ['form-group', 'field', "field-" + schema.type];
|
|
1632
1655
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1633
|
-
classNames.push(
|
|
1656
|
+
classNames.push('field-error has-error has-danger');
|
|
1634
1657
|
}
|
|
1635
1658
|
if (uiSchema !== null && uiSchema !== void 0 && uiSchema.classNames) {
|
|
1636
1659
|
{
|
|
@@ -1641,7 +1664,7 @@ function SchemaFieldRender(props) {
|
|
|
1641
1664
|
if (uiOptions.classNames) {
|
|
1642
1665
|
classNames.push(uiOptions.classNames);
|
|
1643
1666
|
}
|
|
1644
|
-
var helpComponent =
|
|
1667
|
+
var helpComponent = jsxRuntime.jsx(FieldHelpTemplate, {
|
|
1645
1668
|
help: help,
|
|
1646
1669
|
idSchema: idSchema,
|
|
1647
1670
|
schema: schema,
|
|
@@ -1649,7 +1672,7 @@ function SchemaFieldRender(props) {
|
|
|
1649
1672
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
1650
1673
|
registry: registry
|
|
1651
1674
|
});
|
|
1652
|
-
var errorsComponent = hideError ? undefined :
|
|
1675
|
+
var errorsComponent = hideError ? undefined : jsxRuntime.jsx(FieldErrorTemplate, {
|
|
1653
1676
|
errors: __errors,
|
|
1654
1677
|
errorSchema: errorSchema,
|
|
1655
1678
|
idSchema: idSchema,
|
|
@@ -1658,7 +1681,7 @@ function SchemaFieldRender(props) {
|
|
|
1658
1681
|
registry: registry
|
|
1659
1682
|
});
|
|
1660
1683
|
var fieldProps = {
|
|
1661
|
-
description:
|
|
1684
|
+
description: jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
1662
1685
|
id: utils.descriptionId(id),
|
|
1663
1686
|
description: description,
|
|
1664
1687
|
schema: schema,
|
|
@@ -1667,7 +1690,7 @@ function SchemaFieldRender(props) {
|
|
|
1667
1690
|
}),
|
|
1668
1691
|
rawDescription: description,
|
|
1669
1692
|
help: helpComponent,
|
|
1670
|
-
rawHelp: typeof help ===
|
|
1693
|
+
rawHelp: typeof help === 'string' ? help : undefined,
|
|
1671
1694
|
errors: errorsComponent,
|
|
1672
1695
|
rawErrors: hideError ? undefined : __errors,
|
|
1673
1696
|
id: id,
|
|
@@ -1681,7 +1704,7 @@ function SchemaFieldRender(props) {
|
|
|
1681
1704
|
readonly: readonly,
|
|
1682
1705
|
hideError: hideError,
|
|
1683
1706
|
displayLabel: displayLabel,
|
|
1684
|
-
classNames: classNames.join(
|
|
1707
|
+
classNames: classNames.join(' ').trim(),
|
|
1685
1708
|
style: uiOptions.style,
|
|
1686
1709
|
formContext: formContext,
|
|
1687
1710
|
formData: formData,
|
|
@@ -1691,68 +1714,72 @@ function SchemaFieldRender(props) {
|
|
|
1691
1714
|
};
|
|
1692
1715
|
var _AnyOfField = registry.fields.AnyOfField;
|
|
1693
1716
|
var _OneOfField = registry.fields.OneOfField;
|
|
1694
|
-
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[
|
|
1695
|
-
return
|
|
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
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1717
|
+
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:field']) && (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:fieldReplacesAnyOrOneOf']) === true;
|
|
1718
|
+
return jsxRuntime.jsx(FieldTemplate, _extends({}, fieldProps, {
|
|
1719
|
+
children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1720
|
+
children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsxRuntime.jsx(_AnyOfField, {
|
|
1721
|
+
name: name,
|
|
1722
|
+
disabled: disabled,
|
|
1723
|
+
readonly: readonly,
|
|
1724
|
+
hideError: hideError,
|
|
1725
|
+
errorSchema: errorSchema,
|
|
1726
|
+
formData: formData,
|
|
1727
|
+
formContext: formContext,
|
|
1728
|
+
idPrefix: idPrefix,
|
|
1729
|
+
idSchema: idSchema,
|
|
1730
|
+
idSeparator: idSeparator,
|
|
1731
|
+
onBlur: props.onBlur,
|
|
1732
|
+
onChange: props.onChange,
|
|
1733
|
+
onFocus: props.onFocus,
|
|
1734
|
+
options: schema.anyOf.map(function (_schema) {
|
|
1735
|
+
return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
|
|
1736
|
+
}),
|
|
1737
|
+
baseType: schema.type,
|
|
1738
|
+
registry: registry,
|
|
1739
|
+
schema: schema,
|
|
1740
|
+
uiSchema: uiSchema
|
|
1741
|
+
}), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsxRuntime.jsx(_OneOfField, {
|
|
1742
|
+
name: name,
|
|
1743
|
+
disabled: disabled,
|
|
1744
|
+
readonly: readonly,
|
|
1745
|
+
hideError: hideError,
|
|
1746
|
+
errorSchema: errorSchema,
|
|
1747
|
+
formData: formData,
|
|
1748
|
+
formContext: formContext,
|
|
1749
|
+
idPrefix: idPrefix,
|
|
1750
|
+
idSchema: idSchema,
|
|
1751
|
+
idSeparator: idSeparator,
|
|
1752
|
+
onBlur: props.onBlur,
|
|
1753
|
+
onChange: props.onChange,
|
|
1754
|
+
onFocus: props.onFocus,
|
|
1755
|
+
options: schema.oneOf.map(function (_schema) {
|
|
1756
|
+
return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
|
|
1757
|
+
}),
|
|
1758
|
+
baseType: schema.type,
|
|
1759
|
+
registry: registry,
|
|
1760
|
+
schema: schema,
|
|
1761
|
+
uiSchema: uiSchema
|
|
1762
|
+
})]
|
|
1763
|
+
})
|
|
1764
|
+
}));
|
|
1738
1765
|
}
|
|
1739
1766
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
1740
1767
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
1741
1768
|
*/
|
|
1742
|
-
var SchemaField = /*#__PURE__*/function (
|
|
1743
|
-
_inheritsLoose(SchemaField,
|
|
1769
|
+
var SchemaField = /*#__PURE__*/function (_Component) {
|
|
1770
|
+
_inheritsLoose(SchemaField, _Component);
|
|
1744
1771
|
function SchemaField() {
|
|
1745
|
-
return
|
|
1772
|
+
return _Component.apply(this, arguments) || this;
|
|
1746
1773
|
}
|
|
1747
1774
|
var _proto = SchemaField.prototype;
|
|
1748
1775
|
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
1749
1776
|
return !utils.deepEquals(this.props, nextProps);
|
|
1750
1777
|
};
|
|
1751
1778
|
_proto.render = function render() {
|
|
1752
|
-
return
|
|
1779
|
+
return jsxRuntime.jsx(SchemaFieldRender, _extends({}, this.props));
|
|
1753
1780
|
};
|
|
1754
1781
|
return SchemaField;
|
|
1755
|
-
}(
|
|
1782
|
+
}(react.Component);
|
|
1756
1783
|
|
|
1757
1784
|
var _excluded$5 = ["widget", "placeholder"];
|
|
1758
1785
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
@@ -1783,7 +1810,7 @@ function StringField(props) {
|
|
|
1783
1810
|
formContext = registry.formContext,
|
|
1784
1811
|
schemaUtils = registry.schemaUtils;
|
|
1785
1812
|
var enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : undefined;
|
|
1786
|
-
var defaultWidget = enumOptions ?
|
|
1813
|
+
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1787
1814
|
if (format && utils.hasWidget(schema, format, widgets)) {
|
|
1788
1815
|
defaultWidget = format;
|
|
1789
1816
|
}
|
|
@@ -1791,16 +1818,17 @@ function StringField(props) {
|
|
|
1791
1818
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1792
1819
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1793
1820
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1794
|
-
placeholder = _getUiOptions$placeho === void 0 ?
|
|
1821
|
+
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1795
1822
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1796
1823
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
1797
|
-
return
|
|
1824
|
+
return jsxRuntime.jsx(Widget, {
|
|
1798
1825
|
options: _extends({}, options, {
|
|
1799
1826
|
enumOptions: enumOptions
|
|
1800
1827
|
}),
|
|
1801
1828
|
schema: schema,
|
|
1802
1829
|
uiSchema: uiSchema,
|
|
1803
1830
|
id: idSchema.$id,
|
|
1831
|
+
name: name,
|
|
1804
1832
|
label: title === undefined ? name : title,
|
|
1805
1833
|
value: formData,
|
|
1806
1834
|
onChange: onChange,
|
|
@@ -1825,7 +1853,7 @@ function StringField(props) {
|
|
|
1825
1853
|
function NullField(props) {
|
|
1826
1854
|
var formData = props.formData,
|
|
1827
1855
|
onChange = props.onChange;
|
|
1828
|
-
|
|
1856
|
+
react.useEffect(function () {
|
|
1829
1857
|
if (formData === undefined) {
|
|
1830
1858
|
onChange(null);
|
|
1831
1859
|
}
|
|
@@ -1865,8 +1893,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1865
1893
|
if (!description || !displayLabel) {
|
|
1866
1894
|
return null;
|
|
1867
1895
|
}
|
|
1868
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
1869
|
-
return
|
|
1896
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
1897
|
+
return jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
1870
1898
|
id: utils.descriptionId(idSchema),
|
|
1871
1899
|
description: description,
|
|
1872
1900
|
schema: schema,
|
|
@@ -1901,39 +1929,43 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1901
1929
|
flex: 1,
|
|
1902
1930
|
paddingLeft: 6,
|
|
1903
1931
|
paddingRight: 6,
|
|
1904
|
-
fontWeight:
|
|
1932
|
+
fontWeight: 'bold'
|
|
1905
1933
|
};
|
|
1906
|
-
return
|
|
1907
|
-
className: className
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1934
|
+
return jsxRuntime.jsxs("div", {
|
|
1935
|
+
className: className,
|
|
1936
|
+
children: [jsxRuntime.jsx("div", {
|
|
1937
|
+
className: hasToolbar ? 'col-xs-9' : 'col-xs-12',
|
|
1938
|
+
children: children
|
|
1939
|
+
}), hasToolbar && jsxRuntime.jsx("div", {
|
|
1940
|
+
className: 'col-xs-3 array-item-toolbox',
|
|
1941
|
+
children: jsxRuntime.jsxs("div", {
|
|
1942
|
+
className: 'btn-group',
|
|
1943
|
+
style: {
|
|
1944
|
+
display: 'flex',
|
|
1945
|
+
justifyContent: 'space-around'
|
|
1946
|
+
},
|
|
1947
|
+
children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
|
|
1948
|
+
style: btnStyle,
|
|
1949
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
1950
|
+
onClick: onReorderClick(index, index - 1),
|
|
1951
|
+
uiSchema: uiSchema,
|
|
1952
|
+
registry: registry
|
|
1953
|
+
}), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
|
|
1954
|
+
style: btnStyle,
|
|
1955
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
1956
|
+
onClick: onReorderClick(index, index + 1),
|
|
1957
|
+
uiSchema: uiSchema,
|
|
1958
|
+
registry: registry
|
|
1959
|
+
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
1960
|
+
style: btnStyle,
|
|
1961
|
+
disabled: disabled || readonly,
|
|
1962
|
+
onClick: onDropIndexClick(index),
|
|
1963
|
+
uiSchema: uiSchema,
|
|
1964
|
+
registry: registry
|
|
1965
|
+
})]
|
|
1966
|
+
})
|
|
1967
|
+
})]
|
|
1968
|
+
});
|
|
1937
1969
|
}
|
|
1938
1970
|
|
|
1939
1971
|
var _excluded$4 = ["key"];
|
|
@@ -1955,42 +1987,42 @@ function ArrayFieldTemplate(props) {
|
|
|
1955
1987
|
schema = props.schema,
|
|
1956
1988
|
title = props.title;
|
|
1957
1989
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1958
|
-
var ArrayFieldDescriptionTemplate = utils.getTemplate(
|
|
1959
|
-
var ArrayFieldItemTemplate = utils.getTemplate(
|
|
1960
|
-
var ArrayFieldTitleTemplate = utils.getTemplate(
|
|
1990
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
1991
|
+
var ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
1992
|
+
var ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
1961
1993
|
// Button templates are not overridden in the uiSchema
|
|
1962
1994
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
1963
|
-
return
|
|
1995
|
+
return jsxRuntime.jsxs("fieldset", {
|
|
1964
1996
|
className: className,
|
|
1965
|
-
id: idSchema.$id
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
},
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
})
|
|
1997
|
+
id: idSchema.$id,
|
|
1998
|
+
children: [jsxRuntime.jsx(ArrayFieldTitleTemplate, {
|
|
1999
|
+
idSchema: idSchema,
|
|
2000
|
+
title: uiOptions.title || title,
|
|
2001
|
+
required: required,
|
|
2002
|
+
schema: schema,
|
|
2003
|
+
uiSchema: uiSchema,
|
|
2004
|
+
registry: registry
|
|
2005
|
+
}), jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
|
|
2006
|
+
idSchema: idSchema,
|
|
2007
|
+
description: uiOptions.description || schema.description,
|
|
2008
|
+
schema: schema,
|
|
2009
|
+
uiSchema: uiSchema,
|
|
2010
|
+
registry: registry
|
|
2011
|
+
}), jsxRuntime.jsx("div", {
|
|
2012
|
+
className: 'row array-item-list',
|
|
2013
|
+
children: items && items.map(function (_ref) {
|
|
2014
|
+
var key = _ref.key,
|
|
2015
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
2016
|
+
return jsxRuntime.jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
2017
|
+
})
|
|
2018
|
+
}), canAdd && jsxRuntime.jsx(AddButton, {
|
|
2019
|
+
className: 'array-item-add',
|
|
2020
|
+
onClick: onAddClick,
|
|
2021
|
+
disabled: disabled || readonly,
|
|
2022
|
+
uiSchema: uiSchema,
|
|
2023
|
+
registry: registry
|
|
2024
|
+
})]
|
|
2025
|
+
});
|
|
1994
2026
|
}
|
|
1995
2027
|
|
|
1996
2028
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
@@ -2011,8 +2043,8 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2011
2043
|
if (!title || !displayLabel) {
|
|
2012
2044
|
return null;
|
|
2013
2045
|
}
|
|
2014
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
2015
|
-
return
|
|
2046
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
2047
|
+
return jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2016
2048
|
id: utils.titleId(idSchema),
|
|
2017
2049
|
title: title,
|
|
2018
2050
|
required: required,
|
|
@@ -2022,7 +2054,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2022
2054
|
});
|
|
2023
2055
|
}
|
|
2024
2056
|
|
|
2025
|
-
var _excluded$3 = ["id", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2057
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2026
2058
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2027
2059
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2028
2060
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2038,6 +2070,7 @@ function BaseInputTemplate(props) {
|
|
|
2038
2070
|
onBlur = props.onBlur,
|
|
2039
2071
|
onFocus = props.onFocus,
|
|
2040
2072
|
onChange = props.onChange,
|
|
2073
|
+
onChangeOverride = props.onChangeOverride,
|
|
2041
2074
|
options = props.options,
|
|
2042
2075
|
schema = props.schema,
|
|
2043
2076
|
type = props.type,
|
|
@@ -2045,51 +2078,52 @@ function BaseInputTemplate(props) {
|
|
|
2045
2078
|
// Note: since React 15.2.0 we can't forward unknown element attributes, so we
|
|
2046
2079
|
// exclude the "options" and "schema" ones here.
|
|
2047
2080
|
if (!id) {
|
|
2048
|
-
console.log(
|
|
2081
|
+
console.log('No id for', props);
|
|
2049
2082
|
throw new Error("no id for props " + JSON.stringify(props));
|
|
2050
2083
|
}
|
|
2051
2084
|
var inputProps = _extends({}, rest, utils.getInputProps(schema, type, options));
|
|
2052
2085
|
var inputValue;
|
|
2053
|
-
if (inputProps.type ===
|
|
2054
|
-
inputValue = value || value === 0 ? value :
|
|
2086
|
+
if (inputProps.type === 'number' || inputProps.type === 'integer') {
|
|
2087
|
+
inputValue = value || value === 0 ? value : '';
|
|
2055
2088
|
} else {
|
|
2056
|
-
inputValue = value == null ?
|
|
2089
|
+
inputValue = value == null ? '' : value;
|
|
2057
2090
|
}
|
|
2058
|
-
var _onChange =
|
|
2091
|
+
var _onChange = react.useCallback(function (_ref) {
|
|
2059
2092
|
var value = _ref.target.value;
|
|
2060
|
-
return onChange(value ===
|
|
2093
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
2061
2094
|
}, [onChange, options]);
|
|
2062
|
-
var _onBlur =
|
|
2095
|
+
var _onBlur = react.useCallback(function (_ref2) {
|
|
2063
2096
|
var value = _ref2.target.value;
|
|
2064
2097
|
return onBlur(id, value);
|
|
2065
2098
|
}, [onBlur, id]);
|
|
2066
|
-
var _onFocus =
|
|
2099
|
+
var _onFocus = react.useCallback(function (_ref3) {
|
|
2067
2100
|
var value = _ref3.target.value;
|
|
2068
2101
|
return onFocus(id, value);
|
|
2069
2102
|
}, [onFocus, id]);
|
|
2070
|
-
return
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2103
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2104
|
+
children: [jsxRuntime.jsx("input", _extends({
|
|
2105
|
+
id: id,
|
|
2106
|
+
name: id,
|
|
2107
|
+
className: 'form-control',
|
|
2108
|
+
readOnly: readonly,
|
|
2109
|
+
disabled: disabled,
|
|
2110
|
+
autoFocus: autofocus,
|
|
2111
|
+
value: inputValue
|
|
2112
|
+
}, inputProps, {
|
|
2113
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
2114
|
+
onChange: onChangeOverride || _onChange,
|
|
2115
|
+
onBlur: _onBlur,
|
|
2116
|
+
onFocus: _onFocus,
|
|
2117
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
2118
|
+
})), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
|
|
2119
|
+
id: utils.examplesId(id),
|
|
2120
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
2121
|
+
return jsxRuntime.jsx("option", {
|
|
2122
|
+
value: example
|
|
2123
|
+
}, example);
|
|
2124
|
+
})
|
|
2125
|
+
}, "datalist_" + id)]
|
|
2126
|
+
});
|
|
2093
2127
|
}
|
|
2094
2128
|
|
|
2095
2129
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -2104,50 +2138,58 @@ function SubmitButton(_ref) {
|
|
|
2104
2138
|
if (norender) {
|
|
2105
2139
|
return null;
|
|
2106
2140
|
}
|
|
2107
|
-
return
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2141
|
+
return jsxRuntime.jsx("div", {
|
|
2142
|
+
children: jsxRuntime.jsx("button", _extends({
|
|
2143
|
+
type: 'submit'
|
|
2144
|
+
}, submitButtonProps, {
|
|
2145
|
+
className: "btn btn-info " + submitButtonProps.className,
|
|
2146
|
+
children: submitText
|
|
2147
|
+
}))
|
|
2148
|
+
});
|
|
2112
2149
|
}
|
|
2113
2150
|
|
|
2114
2151
|
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2115
2152
|
function IconButton(props) {
|
|
2116
2153
|
var _props$iconType = props.iconType,
|
|
2117
|
-
iconType = _props$iconType === void 0 ?
|
|
2154
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
2118
2155
|
icon = props.icon,
|
|
2119
2156
|
className = props.className,
|
|
2120
2157
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
2121
|
-
return
|
|
2122
|
-
type:
|
|
2158
|
+
return jsxRuntime.jsx("button", _extends({
|
|
2159
|
+
type: 'button',
|
|
2123
2160
|
className: "btn btn-" + iconType + " " + className
|
|
2124
|
-
}, otherProps
|
|
2125
|
-
|
|
2161
|
+
}, otherProps, {
|
|
2162
|
+
children: jsxRuntime.jsx("i", {
|
|
2163
|
+
className: "glyphicon glyphicon-" + icon
|
|
2164
|
+
})
|
|
2126
2165
|
}));
|
|
2127
2166
|
}
|
|
2128
2167
|
function MoveDownButton(props) {
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2168
|
+
var translateString = props.registry.translateString;
|
|
2169
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2170
|
+
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
2171
|
+
className: 'array-item-move-down'
|
|
2132
2172
|
}, props, {
|
|
2133
|
-
icon:
|
|
2173
|
+
icon: 'arrow-down'
|
|
2134
2174
|
}));
|
|
2135
2175
|
}
|
|
2136
2176
|
function MoveUpButton(props) {
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2177
|
+
var translateString = props.registry.translateString;
|
|
2178
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2179
|
+
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
2180
|
+
className: 'array-item-move-up'
|
|
2140
2181
|
}, props, {
|
|
2141
|
-
icon:
|
|
2182
|
+
icon: 'arrow-up'
|
|
2142
2183
|
}));
|
|
2143
2184
|
}
|
|
2144
2185
|
function RemoveButton(props) {
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2186
|
+
var translateString = props.registry.translateString;
|
|
2187
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2188
|
+
title: translateString(utils.TranslatableString.RemoveButton),
|
|
2189
|
+
className: 'array-item-remove'
|
|
2148
2190
|
}, props, {
|
|
2149
|
-
iconType:
|
|
2150
|
-
icon:
|
|
2191
|
+
iconType: 'danger',
|
|
2192
|
+
icon: 'remove'
|
|
2151
2193
|
}));
|
|
2152
2194
|
}
|
|
2153
2195
|
|
|
@@ -2158,19 +2200,22 @@ function AddButton(_ref) {
|
|
|
2158
2200
|
onClick = _ref.onClick,
|
|
2159
2201
|
disabled = _ref.disabled,
|
|
2160
2202
|
registry = _ref.registry;
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2203
|
+
var translateString = registry.translateString;
|
|
2204
|
+
return jsxRuntime.jsx("div", {
|
|
2205
|
+
className: 'row',
|
|
2206
|
+
children: jsxRuntime.jsx("p", {
|
|
2207
|
+
className: "col-xs-3 col-xs-offset-9 text-right " + className,
|
|
2208
|
+
children: jsxRuntime.jsx(IconButton, {
|
|
2209
|
+
iconType: 'info',
|
|
2210
|
+
icon: 'plus',
|
|
2211
|
+
className: 'btn-add col-xs-12',
|
|
2212
|
+
title: translateString(utils.TranslatableString.AddButton),
|
|
2213
|
+
onClick: onClick,
|
|
2214
|
+
disabled: disabled,
|
|
2215
|
+
registry: registry
|
|
2216
|
+
})
|
|
2217
|
+
})
|
|
2218
|
+
});
|
|
2174
2219
|
}
|
|
2175
2220
|
|
|
2176
2221
|
function buttonTemplates() {
|
|
@@ -2193,16 +2238,18 @@ function DescriptionField(props) {
|
|
|
2193
2238
|
if (!description) {
|
|
2194
2239
|
return null;
|
|
2195
2240
|
}
|
|
2196
|
-
if (typeof description ===
|
|
2197
|
-
return
|
|
2241
|
+
if (typeof description === 'string') {
|
|
2242
|
+
return jsxRuntime.jsx("p", {
|
|
2198
2243
|
id: id,
|
|
2199
|
-
className:
|
|
2200
|
-
|
|
2244
|
+
className: 'field-description',
|
|
2245
|
+
children: description
|
|
2246
|
+
});
|
|
2201
2247
|
} else {
|
|
2202
|
-
return
|
|
2248
|
+
return jsxRuntime.jsx("div", {
|
|
2203
2249
|
id: id,
|
|
2204
|
-
className:
|
|
2205
|
-
|
|
2250
|
+
className: 'field-description',
|
|
2251
|
+
children: description
|
|
2252
|
+
});
|
|
2206
2253
|
}
|
|
2207
2254
|
}
|
|
2208
2255
|
|
|
@@ -2211,24 +2258,30 @@ function DescriptionField(props) {
|
|
|
2211
2258
|
* @param props - The `ErrorListProps` for this component
|
|
2212
2259
|
*/
|
|
2213
2260
|
function ErrorList(_ref) {
|
|
2214
|
-
var errors = _ref.errors
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
className:
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
className:
|
|
2227
|
-
|
|
2228
|
-
|
|
2261
|
+
var errors = _ref.errors,
|
|
2262
|
+
registry = _ref.registry;
|
|
2263
|
+
var translateString = registry.translateString;
|
|
2264
|
+
return jsxRuntime.jsxs("div", {
|
|
2265
|
+
className: 'panel panel-danger errors',
|
|
2266
|
+
children: [jsxRuntime.jsx("div", {
|
|
2267
|
+
className: 'panel-heading',
|
|
2268
|
+
children: jsxRuntime.jsx("h3", {
|
|
2269
|
+
className: 'panel-title',
|
|
2270
|
+
children: translateString(utils.TranslatableString.ErrorsLabel)
|
|
2271
|
+
})
|
|
2272
|
+
}), jsxRuntime.jsx("ul", {
|
|
2273
|
+
className: 'list-group',
|
|
2274
|
+
children: errors.map(function (error, i) {
|
|
2275
|
+
return jsxRuntime.jsx("li", {
|
|
2276
|
+
className: 'list-group-item text-danger',
|
|
2277
|
+
children: error.stack
|
|
2278
|
+
}, i);
|
|
2279
|
+
})
|
|
2280
|
+
})]
|
|
2281
|
+
});
|
|
2229
2282
|
}
|
|
2230
2283
|
|
|
2231
|
-
var REQUIRED_FIELD_SYMBOL$1 =
|
|
2284
|
+
var REQUIRED_FIELD_SYMBOL$1 = '*';
|
|
2232
2285
|
/** Renders a label for a field
|
|
2233
2286
|
*
|
|
2234
2287
|
* @param props - The `LabelProps` for this component
|
|
@@ -2240,12 +2293,14 @@ function Label(props) {
|
|
|
2240
2293
|
if (!label) {
|
|
2241
2294
|
return null;
|
|
2242
2295
|
}
|
|
2243
|
-
return
|
|
2244
|
-
className:
|
|
2245
|
-
htmlFor: id
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2296
|
+
return jsxRuntime.jsxs("label", {
|
|
2297
|
+
className: 'control-label',
|
|
2298
|
+
htmlFor: id,
|
|
2299
|
+
children: [label, required && jsxRuntime.jsx("span", {
|
|
2300
|
+
className: 'required',
|
|
2301
|
+
children: REQUIRED_FIELD_SYMBOL$1
|
|
2302
|
+
})]
|
|
2303
|
+
});
|
|
2249
2304
|
}
|
|
2250
2305
|
|
|
2251
2306
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -2266,17 +2321,20 @@ function FieldTemplate(props) {
|
|
|
2266
2321
|
registry = props.registry,
|
|
2267
2322
|
uiSchema = props.uiSchema;
|
|
2268
2323
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
2269
|
-
var WrapIfAdditionalTemplate = utils.getTemplate(
|
|
2324
|
+
var WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
2270
2325
|
if (hidden) {
|
|
2271
|
-
return
|
|
2272
|
-
className:
|
|
2273
|
-
|
|
2326
|
+
return jsxRuntime.jsx("div", {
|
|
2327
|
+
className: 'hidden',
|
|
2328
|
+
children: children
|
|
2329
|
+
});
|
|
2274
2330
|
}
|
|
2275
|
-
return
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2331
|
+
return jsxRuntime.jsxs(WrapIfAdditionalTemplate, _extends({}, props, {
|
|
2332
|
+
children: [displayLabel && jsxRuntime.jsx(Label, {
|
|
2333
|
+
label: label,
|
|
2334
|
+
required: required,
|
|
2335
|
+
id: id
|
|
2336
|
+
}), displayLabel && description ? description : null, children, errors, help]
|
|
2337
|
+
}));
|
|
2280
2338
|
}
|
|
2281
2339
|
|
|
2282
2340
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -2291,17 +2349,20 @@ function FieldErrorTemplate(props) {
|
|
|
2291
2349
|
return null;
|
|
2292
2350
|
}
|
|
2293
2351
|
var id = utils.errorId(idSchema);
|
|
2294
|
-
return
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2352
|
+
return jsxRuntime.jsx("div", {
|
|
2353
|
+
children: jsxRuntime.jsx("ul", {
|
|
2354
|
+
id: id,
|
|
2355
|
+
className: 'error-detail bs-callout bs-callout-info',
|
|
2356
|
+
children: errors.filter(function (elem) {
|
|
2357
|
+
return !!elem;
|
|
2358
|
+
}).map(function (error, index) {
|
|
2359
|
+
return jsxRuntime.jsx("li", {
|
|
2360
|
+
className: 'text-danger',
|
|
2361
|
+
children: error
|
|
2362
|
+
}, index);
|
|
2363
|
+
})
|
|
2364
|
+
})
|
|
2365
|
+
});
|
|
2305
2366
|
}
|
|
2306
2367
|
|
|
2307
2368
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -2315,16 +2376,18 @@ function FieldHelpTemplate(props) {
|
|
|
2315
2376
|
return null;
|
|
2316
2377
|
}
|
|
2317
2378
|
var id = utils.helpId(idSchema);
|
|
2318
|
-
if (typeof help ===
|
|
2319
|
-
return
|
|
2379
|
+
if (typeof help === 'string') {
|
|
2380
|
+
return jsxRuntime.jsx("p", {
|
|
2320
2381
|
id: id,
|
|
2321
|
-
className:
|
|
2322
|
-
|
|
2382
|
+
className: 'help-block',
|
|
2383
|
+
children: help
|
|
2384
|
+
});
|
|
2323
2385
|
}
|
|
2324
|
-
return
|
|
2386
|
+
return jsxRuntime.jsx("div", {
|
|
2325
2387
|
id: id,
|
|
2326
|
-
className:
|
|
2327
|
-
|
|
2388
|
+
className: 'help-block',
|
|
2389
|
+
children: help
|
|
2390
|
+
});
|
|
2328
2391
|
}
|
|
2329
2392
|
|
|
2330
2393
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -2347,37 +2410,38 @@ function ObjectFieldTemplate(props) {
|
|
|
2347
2410
|
title = props.title,
|
|
2348
2411
|
uiSchema = props.uiSchema;
|
|
2349
2412
|
var options = utils.getUiOptions(uiSchema);
|
|
2350
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
2351
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
2413
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
2414
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2352
2415
|
// Button templates are not overridden in the uiSchema
|
|
2353
2416
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2354
|
-
return
|
|
2355
|
-
id: idSchema.$id
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2417
|
+
return jsxRuntime.jsxs("fieldset", {
|
|
2418
|
+
id: idSchema.$id,
|
|
2419
|
+
children: [(options.title || title) && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2420
|
+
id: utils.titleId(idSchema),
|
|
2421
|
+
title: options.title || title,
|
|
2422
|
+
required: required,
|
|
2423
|
+
schema: schema,
|
|
2424
|
+
uiSchema: uiSchema,
|
|
2425
|
+
registry: registry
|
|
2426
|
+
}), (options.description || description) && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2427
|
+
id: utils.descriptionId(idSchema),
|
|
2428
|
+
description: options.description || description,
|
|
2429
|
+
schema: schema,
|
|
2430
|
+
uiSchema: uiSchema,
|
|
2431
|
+
registry: registry
|
|
2432
|
+
}), properties.map(function (prop) {
|
|
2433
|
+
return prop.content;
|
|
2434
|
+
}), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(AddButton, {
|
|
2435
|
+
className: 'object-property-expand',
|
|
2436
|
+
onClick: onAddClick(schema),
|
|
2437
|
+
disabled: disabled || readonly,
|
|
2438
|
+
uiSchema: uiSchema,
|
|
2439
|
+
registry: registry
|
|
2440
|
+
})]
|
|
2441
|
+
});
|
|
2378
2442
|
}
|
|
2379
2443
|
|
|
2380
|
-
var REQUIRED_FIELD_SYMBOL =
|
|
2444
|
+
var REQUIRED_FIELD_SYMBOL = '*';
|
|
2381
2445
|
/** The `TitleField` is the template to use to render the title of a field
|
|
2382
2446
|
*
|
|
2383
2447
|
* @param props - The `TitleFieldProps` for this component
|
|
@@ -2386,11 +2450,13 @@ function TitleField(props) {
|
|
|
2386
2450
|
var id = props.id,
|
|
2387
2451
|
title = props.title,
|
|
2388
2452
|
required = props.required;
|
|
2389
|
-
return
|
|
2390
|
-
id: id
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2453
|
+
return jsxRuntime.jsxs("legend", {
|
|
2454
|
+
id: id,
|
|
2455
|
+
children: [title, required && jsxRuntime.jsx("span", {
|
|
2456
|
+
className: 'required',
|
|
2457
|
+
children: REQUIRED_FIELD_SYMBOL
|
|
2458
|
+
})]
|
|
2459
|
+
});
|
|
2394
2460
|
}
|
|
2395
2461
|
|
|
2396
2462
|
/** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
|
|
@@ -2401,10 +2467,29 @@ function TitleField(props) {
|
|
|
2401
2467
|
function UnsupportedField(props) {
|
|
2402
2468
|
var schema = props.schema,
|
|
2403
2469
|
idSchema = props.idSchema,
|
|
2404
|
-
reason = props.reason
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2470
|
+
reason = props.reason,
|
|
2471
|
+
registry = props.registry;
|
|
2472
|
+
var translateString = registry.translateString;
|
|
2473
|
+
var translateEnum = utils.TranslatableString.UnsupportedField;
|
|
2474
|
+
var translateParams = [];
|
|
2475
|
+
if (idSchema && idSchema.$id) {
|
|
2476
|
+
translateEnum = utils.TranslatableString.UnsupportedFieldWithId;
|
|
2477
|
+
translateParams.push(idSchema.$id);
|
|
2478
|
+
}
|
|
2479
|
+
if (reason) {
|
|
2480
|
+
translateEnum = translateEnum === utils.TranslatableString.UnsupportedField ? utils.TranslatableString.UnsupportedFieldWithReason : utils.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2481
|
+
translateParams.push(reason);
|
|
2482
|
+
}
|
|
2483
|
+
return jsxRuntime.jsxs("div", {
|
|
2484
|
+
className: 'unsupported-field',
|
|
2485
|
+
children: [jsxRuntime.jsx("p", {
|
|
2486
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
2487
|
+
children: translateString(translateEnum, translateParams)
|
|
2488
|
+
})
|
|
2489
|
+
}), schema && jsxRuntime.jsx("pre", {
|
|
2490
|
+
children: JSON.stringify(schema, null, 2)
|
|
2491
|
+
})]
|
|
2492
|
+
});
|
|
2408
2493
|
}
|
|
2409
2494
|
|
|
2410
2495
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -2426,51 +2511,60 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2426
2511
|
children = props.children,
|
|
2427
2512
|
uiSchema = props.uiSchema,
|
|
2428
2513
|
registry = props.registry;
|
|
2514
|
+
var templates = registry.templates,
|
|
2515
|
+
translateString = registry.translateString;
|
|
2429
2516
|
// Button templates are not overridden in the uiSchema
|
|
2430
|
-
var RemoveButton =
|
|
2431
|
-
var keyLabel = label
|
|
2517
|
+
var RemoveButton = templates.ButtonTemplates.RemoveButton;
|
|
2518
|
+
var keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
2432
2519
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2433
2520
|
if (!additional) {
|
|
2434
|
-
return
|
|
2521
|
+
return jsxRuntime.jsx("div", {
|
|
2435
2522
|
className: classNames,
|
|
2436
|
-
style: style
|
|
2437
|
-
|
|
2523
|
+
style: style,
|
|
2524
|
+
children: children
|
|
2525
|
+
});
|
|
2438
2526
|
}
|
|
2439
|
-
return
|
|
2527
|
+
return jsxRuntime.jsx("div", {
|
|
2440
2528
|
className: classNames,
|
|
2441
|
-
style: style
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2529
|
+
style: style,
|
|
2530
|
+
children: jsxRuntime.jsxs("div", {
|
|
2531
|
+
className: 'row',
|
|
2532
|
+
children: [jsxRuntime.jsx("div", {
|
|
2533
|
+
className: 'col-xs-5 form-additional',
|
|
2534
|
+
children: jsxRuntime.jsxs("div", {
|
|
2535
|
+
className: 'form-group',
|
|
2536
|
+
children: [jsxRuntime.jsx(Label, {
|
|
2537
|
+
label: keyLabel,
|
|
2538
|
+
required: required,
|
|
2539
|
+
id: id + "-key"
|
|
2540
|
+
}), jsxRuntime.jsx("input", {
|
|
2541
|
+
className: 'form-control',
|
|
2542
|
+
type: 'text',
|
|
2543
|
+
id: id + "-key",
|
|
2544
|
+
onBlur: function onBlur(event) {
|
|
2545
|
+
return onKeyChange(event.target.value);
|
|
2546
|
+
},
|
|
2547
|
+
defaultValue: label
|
|
2548
|
+
})]
|
|
2549
|
+
})
|
|
2550
|
+
}), jsxRuntime.jsx("div", {
|
|
2551
|
+
className: 'form-additional form-group col-xs-5',
|
|
2552
|
+
children: children
|
|
2553
|
+
}), jsxRuntime.jsx("div", {
|
|
2554
|
+
className: 'col-xs-2',
|
|
2555
|
+
children: jsxRuntime.jsx(RemoveButton, {
|
|
2556
|
+
className: 'array-item-remove btn-block',
|
|
2557
|
+
style: {
|
|
2558
|
+
border: '0'
|
|
2559
|
+
},
|
|
2560
|
+
disabled: disabled || readonly,
|
|
2561
|
+
onClick: onDropPropertyClick(label),
|
|
2562
|
+
uiSchema: uiSchema,
|
|
2563
|
+
registry: registry
|
|
2564
|
+
})
|
|
2565
|
+
})]
|
|
2566
|
+
})
|
|
2567
|
+
});
|
|
2474
2568
|
}
|
|
2475
2569
|
|
|
2476
2570
|
function templates() {
|
|
@@ -2519,29 +2613,29 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
2519
2613
|
minute = state.minute,
|
|
2520
2614
|
second = state.second;
|
|
2521
2615
|
var data = [{
|
|
2522
|
-
type:
|
|
2616
|
+
type: 'year',
|
|
2523
2617
|
range: yearsRange,
|
|
2524
2618
|
value: year
|
|
2525
2619
|
}, {
|
|
2526
|
-
type:
|
|
2620
|
+
type: 'month',
|
|
2527
2621
|
range: [1, 12],
|
|
2528
2622
|
value: month
|
|
2529
2623
|
}, {
|
|
2530
|
-
type:
|
|
2624
|
+
type: 'day',
|
|
2531
2625
|
range: [1, 31],
|
|
2532
2626
|
value: day
|
|
2533
2627
|
}];
|
|
2534
2628
|
if (time) {
|
|
2535
2629
|
data.push({
|
|
2536
|
-
type:
|
|
2630
|
+
type: 'hour',
|
|
2537
2631
|
range: [0, 23],
|
|
2538
2632
|
value: hour
|
|
2539
2633
|
}, {
|
|
2540
|
-
type:
|
|
2634
|
+
type: 'minute',
|
|
2541
2635
|
range: [0, 59],
|
|
2542
2636
|
value: minute
|
|
2543
2637
|
}, {
|
|
2544
|
-
type:
|
|
2638
|
+
type: 'second',
|
|
2545
2639
|
range: [0, 59],
|
|
2546
2640
|
value: second
|
|
2547
2641
|
});
|
|
@@ -2554,20 +2648,22 @@ function DateElement(_ref) {
|
|
|
2554
2648
|
value = _ref.value,
|
|
2555
2649
|
select = _ref.select,
|
|
2556
2650
|
rootId = _ref.rootId,
|
|
2651
|
+
name = _ref.name,
|
|
2557
2652
|
disabled = _ref.disabled,
|
|
2558
2653
|
readonly = _ref.readonly,
|
|
2559
2654
|
autofocus = _ref.autofocus,
|
|
2560
2655
|
registry = _ref.registry,
|
|
2561
2656
|
onBlur = _ref.onBlur,
|
|
2562
2657
|
onFocus = _ref.onFocus;
|
|
2563
|
-
var id = rootId +
|
|
2658
|
+
var id = rootId + '_' + type;
|
|
2564
2659
|
var SelectWidget = registry.widgets.SelectWidget;
|
|
2565
|
-
return
|
|
2660
|
+
return jsxRuntime.jsx(SelectWidget, {
|
|
2566
2661
|
schema: {
|
|
2567
|
-
type:
|
|
2662
|
+
type: 'integer'
|
|
2568
2663
|
},
|
|
2569
2664
|
id: id,
|
|
2570
|
-
|
|
2665
|
+
name: name,
|
|
2666
|
+
className: 'form-control',
|
|
2571
2667
|
options: {
|
|
2572
2668
|
enumOptions: rangeOptions(range[0], range[1])
|
|
2573
2669
|
},
|
|
@@ -2582,7 +2678,7 @@ function DateElement(_ref) {
|
|
|
2582
2678
|
onBlur: onBlur,
|
|
2583
2679
|
onFocus: onFocus,
|
|
2584
2680
|
registry: registry,
|
|
2585
|
-
label:
|
|
2681
|
+
label: '',
|
|
2586
2682
|
"aria-describedby": utils.ariaDescribedByIds(rootId)
|
|
2587
2683
|
});
|
|
2588
2684
|
}
|
|
@@ -2600,32 +2696,34 @@ function AltDateWidget(_ref2) {
|
|
|
2600
2696
|
autofocus = _ref2$autofocus === void 0 ? false : _ref2$autofocus,
|
|
2601
2697
|
options = _ref2.options,
|
|
2602
2698
|
id = _ref2.id,
|
|
2699
|
+
name = _ref2.name,
|
|
2603
2700
|
registry = _ref2.registry,
|
|
2604
2701
|
onBlur = _ref2.onBlur,
|
|
2605
2702
|
onFocus = _ref2.onFocus,
|
|
2606
2703
|
onChange = _ref2.onChange,
|
|
2607
2704
|
value = _ref2.value;
|
|
2608
|
-
var
|
|
2705
|
+
var translateString = registry.translateString;
|
|
2706
|
+
var _useReducer = react.useReducer(function (state, action) {
|
|
2609
2707
|
return _extends({}, state, action);
|
|
2610
2708
|
}, utils.parseDateString(value, time)),
|
|
2611
2709
|
state = _useReducer[0],
|
|
2612
2710
|
setState = _useReducer[1];
|
|
2613
|
-
|
|
2711
|
+
react.useEffect(function () {
|
|
2614
2712
|
if (value && value !== utils.toDateString(state, time)) {
|
|
2615
2713
|
setState(utils.parseDateString(value, time));
|
|
2616
2714
|
}
|
|
2617
2715
|
}, [value, state, time]);
|
|
2618
|
-
|
|
2716
|
+
react.useEffect(function () {
|
|
2619
2717
|
if (readyForChange(state)) {
|
|
2620
2718
|
// Only propagate to parent state if we have a complete date{time}
|
|
2621
2719
|
onChange(utils.toDateString(state, time));
|
|
2622
2720
|
}
|
|
2623
2721
|
}, [state, time, onChange]);
|
|
2624
|
-
var handleChange =
|
|
2722
|
+
var handleChange = react.useCallback(function (property, value) {
|
|
2625
2723
|
var _setState;
|
|
2626
2724
|
setState((_setState = {}, _setState[property] = value, _setState));
|
|
2627
2725
|
}, []);
|
|
2628
|
-
var handleSetNow =
|
|
2726
|
+
var handleSetNow = react.useCallback(function (event) {
|
|
2629
2727
|
event.preventDefault();
|
|
2630
2728
|
if (disabled || readonly) {
|
|
2631
2729
|
return;
|
|
@@ -2633,44 +2731,50 @@ function AltDateWidget(_ref2) {
|
|
|
2633
2731
|
var nowDateObj = utils.parseDateString(new Date().toJSON(), time);
|
|
2634
2732
|
setState(nowDateObj);
|
|
2635
2733
|
}, [disabled, readonly, time]);
|
|
2636
|
-
var handleClear =
|
|
2734
|
+
var handleClear = react.useCallback(function (event) {
|
|
2637
2735
|
event.preventDefault();
|
|
2638
2736
|
if (disabled || readonly) {
|
|
2639
2737
|
return;
|
|
2640
2738
|
}
|
|
2641
|
-
setState(utils.parseDateString(
|
|
2739
|
+
setState(utils.parseDateString('', time));
|
|
2642
2740
|
onChange(undefined);
|
|
2643
2741
|
}, [disabled, readonly, time, onChange]);
|
|
2644
|
-
return
|
|
2645
|
-
className:
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2742
|
+
return jsxRuntime.jsxs("ul", {
|
|
2743
|
+
className: 'list-inline',
|
|
2744
|
+
children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2745
|
+
return jsxRuntime.jsx("li", {
|
|
2746
|
+
className: 'list-inline-item',
|
|
2747
|
+
children: jsxRuntime.jsx(DateElement, _extends({
|
|
2748
|
+
rootId: id,
|
|
2749
|
+
name: name,
|
|
2750
|
+
select: handleChange
|
|
2751
|
+
}, elemProps, {
|
|
2752
|
+
disabled: disabled,
|
|
2753
|
+
readonly: readonly,
|
|
2754
|
+
registry: registry,
|
|
2755
|
+
onBlur: onBlur,
|
|
2756
|
+
onFocus: onFocus,
|
|
2757
|
+
autofocus: autofocus && i === 0
|
|
2758
|
+
}))
|
|
2759
|
+
}, i);
|
|
2760
|
+
}), (options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && jsxRuntime.jsx("li", {
|
|
2761
|
+
className: 'list-inline-item',
|
|
2762
|
+
children: jsxRuntime.jsx("a", {
|
|
2763
|
+
href: '#',
|
|
2764
|
+
className: 'btn btn-info btn-now',
|
|
2765
|
+
onClick: handleSetNow,
|
|
2766
|
+
children: translateString(utils.TranslatableString.NowLabel)
|
|
2767
|
+
})
|
|
2768
|
+
}), (options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && jsxRuntime.jsx("li", {
|
|
2769
|
+
className: 'list-inline-item',
|
|
2770
|
+
children: jsxRuntime.jsx("a", {
|
|
2771
|
+
href: '#',
|
|
2772
|
+
className: 'btn btn-warning btn-clear',
|
|
2773
|
+
onClick: handleClear,
|
|
2774
|
+
children: translateString(utils.TranslatableString.ClearLabel)
|
|
2775
|
+
})
|
|
2776
|
+
})]
|
|
2777
|
+
});
|
|
2674
2778
|
}
|
|
2675
2779
|
|
|
2676
2780
|
var _excluded$1 = ["time"];
|
|
@@ -2684,7 +2788,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2684
2788
|
time = _ref$time === void 0 ? true : _ref$time,
|
|
2685
2789
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2686
2790
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
2687
|
-
return
|
|
2791
|
+
return jsxRuntime.jsx(AltDateWidget, _extends({
|
|
2688
2792
|
time: time
|
|
2689
2793
|
}, props));
|
|
2690
2794
|
}
|
|
@@ -2709,41 +2813,46 @@ function CheckboxWidget(_ref) {
|
|
|
2709
2813
|
onFocus = _ref.onFocus,
|
|
2710
2814
|
onChange = _ref.onChange,
|
|
2711
2815
|
registry = _ref.registry;
|
|
2712
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
2816
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2713
2817
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
2714
2818
|
// the "required" attribute if the field value must be "true", due to the
|
|
2715
2819
|
// "const" or "enum" keywords
|
|
2716
2820
|
var required = utils.schemaRequiresTrueValue(schema);
|
|
2717
|
-
var handleChange =
|
|
2821
|
+
var handleChange = react.useCallback(function (event) {
|
|
2718
2822
|
return onChange(event.target.checked);
|
|
2719
2823
|
}, [onChange]);
|
|
2720
|
-
var handleBlur =
|
|
2824
|
+
var handleBlur = react.useCallback(function (event) {
|
|
2721
2825
|
return onBlur(id, event.target.checked);
|
|
2722
2826
|
}, [onBlur, id]);
|
|
2723
|
-
var handleFocus =
|
|
2827
|
+
var handleFocus = react.useCallback(function (event) {
|
|
2724
2828
|
return onFocus(id, event.target.checked);
|
|
2725
2829
|
}, [onFocus, id]);
|
|
2726
|
-
return
|
|
2727
|
-
className: "checkbox " + (disabled || readonly ?
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2830
|
+
return jsxRuntime.jsxs("div", {
|
|
2831
|
+
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2832
|
+
children: [schema.description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2833
|
+
id: utils.descriptionId(id),
|
|
2834
|
+
description: schema.description,
|
|
2835
|
+
schema: schema,
|
|
2836
|
+
uiSchema: uiSchema,
|
|
2837
|
+
registry: registry
|
|
2838
|
+
}), jsxRuntime.jsxs("label", {
|
|
2839
|
+
children: [jsxRuntime.jsx("input", {
|
|
2840
|
+
type: 'checkbox',
|
|
2841
|
+
id: id,
|
|
2842
|
+
name: id,
|
|
2843
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
2844
|
+
required: required,
|
|
2845
|
+
disabled: disabled || readonly,
|
|
2846
|
+
autoFocus: autofocus,
|
|
2847
|
+
onChange: handleChange,
|
|
2848
|
+
onBlur: handleBlur,
|
|
2849
|
+
onFocus: handleFocus,
|
|
2850
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2851
|
+
}), jsxRuntime.jsx("span", {
|
|
2852
|
+
children: label
|
|
2853
|
+
})]
|
|
2854
|
+
})]
|
|
2855
|
+
});
|
|
2747
2856
|
}
|
|
2748
2857
|
|
|
2749
2858
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
@@ -2768,49 +2877,56 @@ function CheckboxesWidget(_ref) {
|
|
|
2768
2877
|
onBlur = _ref.onBlur,
|
|
2769
2878
|
onFocus = _ref.onFocus;
|
|
2770
2879
|
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2771
|
-
var handleBlur =
|
|
2880
|
+
var handleBlur = react.useCallback(function (_ref2) {
|
|
2772
2881
|
var value = _ref2.target.value;
|
|
2773
2882
|
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2774
2883
|
}, [onBlur, id]);
|
|
2775
|
-
var handleFocus =
|
|
2884
|
+
var handleFocus = react.useCallback(function (_ref3) {
|
|
2776
2885
|
var value = _ref3.target.value;
|
|
2777
2886
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2778
2887
|
}, [onFocus, id]);
|
|
2779
|
-
return
|
|
2780
|
-
className:
|
|
2781
|
-
id: id
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2888
|
+
return jsxRuntime.jsx("div", {
|
|
2889
|
+
className: 'checkboxes',
|
|
2890
|
+
id: id,
|
|
2891
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2892
|
+
var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
2893
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2894
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
2895
|
+
var handleChange = function handleChange(event) {
|
|
2896
|
+
if (event.target.checked) {
|
|
2897
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
2898
|
+
} else {
|
|
2899
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
var checkbox = jsxRuntime.jsxs("span", {
|
|
2903
|
+
children: [jsxRuntime.jsx("input", {
|
|
2904
|
+
type: 'checkbox',
|
|
2905
|
+
id: utils.optionId(id, index),
|
|
2906
|
+
name: id,
|
|
2907
|
+
checked: checked,
|
|
2908
|
+
value: String(index),
|
|
2909
|
+
disabled: disabled || itemDisabled || readonly,
|
|
2910
|
+
autoFocus: autofocus && index === 0,
|
|
2911
|
+
onChange: handleChange,
|
|
2912
|
+
onBlur: handleBlur,
|
|
2913
|
+
onFocus: handleFocus,
|
|
2914
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2915
|
+
}), jsxRuntime.jsx("span", {
|
|
2916
|
+
children: option.label
|
|
2917
|
+
})]
|
|
2918
|
+
});
|
|
2919
|
+
return inline ? jsxRuntime.jsx("label", {
|
|
2920
|
+
className: "checkbox-inline " + disabledCls,
|
|
2921
|
+
children: checkbox
|
|
2922
|
+
}, index) : jsxRuntime.jsx("div", {
|
|
2923
|
+
className: "checkbox " + disabledCls,
|
|
2924
|
+
children: jsxRuntime.jsx("label", {
|
|
2925
|
+
children: checkbox
|
|
2926
|
+
})
|
|
2927
|
+
}, index);
|
|
2928
|
+
})
|
|
2929
|
+
});
|
|
2814
2930
|
}
|
|
2815
2931
|
|
|
2816
2932
|
/** The `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
|
|
@@ -2823,9 +2939,9 @@ function ColorWidget(props) {
|
|
|
2823
2939
|
readonly = props.readonly,
|
|
2824
2940
|
options = props.options,
|
|
2825
2941
|
registry = props.registry;
|
|
2826
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2827
|
-
return
|
|
2828
|
-
type:
|
|
2942
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2943
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2944
|
+
type: 'color'
|
|
2829
2945
|
}, props, {
|
|
2830
2946
|
disabled: disabled || readonly
|
|
2831
2947
|
}));
|
|
@@ -2840,12 +2956,12 @@ function DateWidget(props) {
|
|
|
2840
2956
|
var onChange = props.onChange,
|
|
2841
2957
|
options = props.options,
|
|
2842
2958
|
registry = props.registry;
|
|
2843
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2844
|
-
var handleChange =
|
|
2959
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2960
|
+
var handleChange = react.useCallback(function (value) {
|
|
2845
2961
|
return onChange(value || undefined);
|
|
2846
2962
|
}, [onChange]);
|
|
2847
|
-
return
|
|
2848
|
-
type:
|
|
2963
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2964
|
+
type: 'date'
|
|
2849
2965
|
}, props, {
|
|
2850
2966
|
onChange: handleChange
|
|
2851
2967
|
}));
|
|
@@ -2861,9 +2977,9 @@ function DateTimeWidget(props) {
|
|
|
2861
2977
|
value = props.value,
|
|
2862
2978
|
options = props.options,
|
|
2863
2979
|
registry = props.registry;
|
|
2864
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2865
|
-
return
|
|
2866
|
-
type:
|
|
2980
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2981
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2982
|
+
type: 'datetime-local'
|
|
2867
2983
|
}, props, {
|
|
2868
2984
|
value: utils.utcToLocal(value),
|
|
2869
2985
|
onChange: function onChange(value) {
|
|
@@ -2879,9 +2995,9 @@ function DateTimeWidget(props) {
|
|
|
2879
2995
|
function EmailWidget(props) {
|
|
2880
2996
|
var options = props.options,
|
|
2881
2997
|
registry = props.registry;
|
|
2882
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2883
|
-
return
|
|
2884
|
-
type:
|
|
2998
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2999
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3000
|
+
type: 'email'
|
|
2885
3001
|
}, props));
|
|
2886
3002
|
}
|
|
2887
3003
|
|
|
@@ -2889,7 +3005,7 @@ function addNameToDataURL(dataURL, name) {
|
|
|
2889
3005
|
if (dataURL === null) {
|
|
2890
3006
|
return null;
|
|
2891
3007
|
}
|
|
2892
|
-
return dataURL.replace(
|
|
3008
|
+
return dataURL.replace(';base64', ";name=" + encodeURIComponent(name) + ";base64");
|
|
2893
3009
|
}
|
|
2894
3010
|
function processFile(file) {
|
|
2895
3011
|
var name = file.name,
|
|
@@ -2900,7 +3016,7 @@ function processFile(file) {
|
|
|
2900
3016
|
reader.onerror = reject;
|
|
2901
3017
|
reader.onload = function (event) {
|
|
2902
3018
|
var _event$target;
|
|
2903
|
-
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) ===
|
|
3019
|
+
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) === 'string') {
|
|
2904
3020
|
resolve({
|
|
2905
3021
|
dataURL: addNameToDataURL(event.target.result, name),
|
|
2906
3022
|
name: name,
|
|
@@ -2923,24 +3039,29 @@ function processFiles(files) {
|
|
|
2923
3039
|
return Promise.all(Array.from(files).map(processFile));
|
|
2924
3040
|
}
|
|
2925
3041
|
function FilesInfo(_ref) {
|
|
2926
|
-
var filesInfo = _ref.filesInfo
|
|
3042
|
+
var filesInfo = _ref.filesInfo,
|
|
3043
|
+
registry = _ref.registry;
|
|
2927
3044
|
if (filesInfo.length === 0) {
|
|
2928
3045
|
return null;
|
|
2929
3046
|
}
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
3047
|
+
var translateString = registry.translateString;
|
|
3048
|
+
return jsxRuntime.jsx("ul", {
|
|
3049
|
+
className: 'file-info',
|
|
3050
|
+
children: filesInfo.map(function (fileInfo, key) {
|
|
3051
|
+
var name = fileInfo.name,
|
|
3052
|
+
size = fileInfo.size,
|
|
3053
|
+
type = fileInfo.type;
|
|
3054
|
+
return jsxRuntime.jsx("li", {
|
|
3055
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3056
|
+
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3057
|
+
})
|
|
3058
|
+
}, key);
|
|
3059
|
+
})
|
|
3060
|
+
});
|
|
2940
3061
|
}
|
|
2941
3062
|
function extractFileInfo(dataURLs) {
|
|
2942
3063
|
return dataURLs.filter(function (dataURL) {
|
|
2943
|
-
return
|
|
3064
|
+
return dataURL;
|
|
2944
3065
|
}).map(function (dataURL) {
|
|
2945
3066
|
var _dataURItoBlob = utils.dataURItoBlob(dataURL),
|
|
2946
3067
|
blob = _dataURItoBlob.blob,
|
|
@@ -2956,23 +3077,22 @@ function extractFileInfo(dataURLs) {
|
|
|
2956
3077
|
* The `FileWidget` is a widget for rendering file upload fields.
|
|
2957
3078
|
* It is typically used with a string property with data-url format.
|
|
2958
3079
|
*/
|
|
2959
|
-
function FileWidget(
|
|
2960
|
-
var
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
var extractedFilesInfo = React.useMemo(function () {
|
|
3080
|
+
function FileWidget(props) {
|
|
3081
|
+
var disabled = props.disabled,
|
|
3082
|
+
readonly = props.readonly,
|
|
3083
|
+
multiple = props.multiple,
|
|
3084
|
+
onChange = props.onChange,
|
|
3085
|
+
value = props.value,
|
|
3086
|
+
options = props.options,
|
|
3087
|
+
registry = props.registry;
|
|
3088
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3089
|
+
var extractedFilesInfo = react.useMemo(function () {
|
|
2970
3090
|
return Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value]);
|
|
2971
3091
|
}, [value]);
|
|
2972
|
-
var _useState =
|
|
3092
|
+
var _useState = react.useState(extractedFilesInfo),
|
|
2973
3093
|
filesInfo = _useState[0],
|
|
2974
3094
|
setFilesInfo = _useState[1];
|
|
2975
|
-
var handleChange =
|
|
3095
|
+
var handleChange = react.useCallback(function (event) {
|
|
2976
3096
|
if (!event.target.files) {
|
|
2977
3097
|
return;
|
|
2978
3098
|
}
|
|
@@ -2988,20 +3108,18 @@ function FileWidget(_ref2) {
|
|
|
2988
3108
|
}
|
|
2989
3109
|
});
|
|
2990
3110
|
}, [multiple, onChange]);
|
|
2991
|
-
return
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
})
|
|
3003
|
-
filesInfo: filesInfo
|
|
3004
|
-
}));
|
|
3111
|
+
return jsxRuntime.jsxs("div", {
|
|
3112
|
+
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({}, props, {
|
|
3113
|
+
disabled: disabled || readonly,
|
|
3114
|
+
type: 'file',
|
|
3115
|
+
onChangeOverride: handleChange,
|
|
3116
|
+
value: '',
|
|
3117
|
+
accept: options.accept ? String(options.accept) : undefined
|
|
3118
|
+
})), jsxRuntime.jsx(FilesInfo, {
|
|
3119
|
+
filesInfo: filesInfo,
|
|
3120
|
+
registry: registry
|
|
3121
|
+
})]
|
|
3122
|
+
});
|
|
3005
3123
|
}
|
|
3006
3124
|
|
|
3007
3125
|
/** The `HiddenWidget` is a widget for rendering a hidden input field.
|
|
@@ -3012,11 +3130,11 @@ function FileWidget(_ref2) {
|
|
|
3012
3130
|
function HiddenWidget(_ref) {
|
|
3013
3131
|
var id = _ref.id,
|
|
3014
3132
|
value = _ref.value;
|
|
3015
|
-
return
|
|
3016
|
-
type:
|
|
3133
|
+
return jsxRuntime.jsx("input", {
|
|
3134
|
+
type: 'hidden',
|
|
3017
3135
|
id: id,
|
|
3018
3136
|
name: id,
|
|
3019
|
-
value: typeof value ===
|
|
3137
|
+
value: typeof value === 'undefined' ? '' : value
|
|
3020
3138
|
});
|
|
3021
3139
|
}
|
|
3022
3140
|
|
|
@@ -3027,9 +3145,9 @@ function HiddenWidget(_ref) {
|
|
|
3027
3145
|
function PasswordWidget(props) {
|
|
3028
3146
|
var options = props.options,
|
|
3029
3147
|
registry = props.registry;
|
|
3030
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3031
|
-
return
|
|
3032
|
-
type:
|
|
3148
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3149
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3150
|
+
type: 'password'
|
|
3033
3151
|
}, props));
|
|
3034
3152
|
}
|
|
3035
3153
|
|
|
@@ -3056,46 +3174,53 @@ function RadioWidget(_ref) {
|
|
|
3056
3174
|
enumDisabled = options.enumDisabled,
|
|
3057
3175
|
inline = options.inline,
|
|
3058
3176
|
emptyValue = options.emptyValue;
|
|
3059
|
-
var handleBlur =
|
|
3177
|
+
var handleBlur = react.useCallback(function (_ref2) {
|
|
3060
3178
|
var value = _ref2.target.value;
|
|
3061
3179
|
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3062
3180
|
}, [onBlur, id]);
|
|
3063
|
-
var handleFocus =
|
|
3181
|
+
var handleFocus = react.useCallback(function (_ref3) {
|
|
3064
3182
|
var value = _ref3.target.value;
|
|
3065
3183
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3066
3184
|
}, [onFocus, id]);
|
|
3067
|
-
return
|
|
3068
|
-
className:
|
|
3069
|
-
id: id
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3185
|
+
return jsxRuntime.jsx("div", {
|
|
3186
|
+
className: 'field-radio-group',
|
|
3187
|
+
id: id,
|
|
3188
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
3189
|
+
var checked = utils.enumOptionsIsSelected(option.value, value);
|
|
3190
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3191
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
3192
|
+
var handleChange = function handleChange() {
|
|
3193
|
+
return onChange(option.value);
|
|
3194
|
+
};
|
|
3195
|
+
var radio = jsxRuntime.jsxs("span", {
|
|
3196
|
+
children: [jsxRuntime.jsx("input", {
|
|
3197
|
+
type: 'radio',
|
|
3198
|
+
id: utils.optionId(id, i),
|
|
3199
|
+
checked: checked,
|
|
3200
|
+
name: name,
|
|
3201
|
+
required: required,
|
|
3202
|
+
value: String(i),
|
|
3203
|
+
disabled: disabled || itemDisabled || readonly,
|
|
3204
|
+
autoFocus: autofocus && i === 0,
|
|
3205
|
+
onChange: handleChange,
|
|
3206
|
+
onBlur: handleBlur,
|
|
3207
|
+
onFocus: handleFocus,
|
|
3208
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3209
|
+
}), jsxRuntime.jsx("span", {
|
|
3210
|
+
children: option.label
|
|
3211
|
+
})]
|
|
3212
|
+
});
|
|
3213
|
+
return inline ? jsxRuntime.jsx("label", {
|
|
3214
|
+
className: "radio-inline " + disabledCls,
|
|
3215
|
+
children: radio
|
|
3216
|
+
}, i) : jsxRuntime.jsx("div", {
|
|
3217
|
+
className: "radio " + disabledCls,
|
|
3218
|
+
children: jsxRuntime.jsx("label", {
|
|
3219
|
+
children: radio
|
|
3220
|
+
})
|
|
3221
|
+
}, i);
|
|
3222
|
+
})
|
|
3223
|
+
});
|
|
3099
3224
|
}
|
|
3100
3225
|
|
|
3101
3226
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -3106,13 +3231,15 @@ function RadioWidget(_ref) {
|
|
|
3106
3231
|
function RangeWidget(props) {
|
|
3107
3232
|
var value = props.value,
|
|
3108
3233
|
BaseInputTemplate = props.registry.templates.BaseInputTemplate;
|
|
3109
|
-
return
|
|
3110
|
-
className:
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3234
|
+
return jsxRuntime.jsxs("div", {
|
|
3235
|
+
className: 'field-range-wrapper',
|
|
3236
|
+
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3237
|
+
type: 'range'
|
|
3238
|
+
}, props)), jsxRuntime.jsx("span", {
|
|
3239
|
+
className: 'range-view',
|
|
3240
|
+
children: value
|
|
3241
|
+
})]
|
|
3242
|
+
});
|
|
3116
3243
|
}
|
|
3117
3244
|
|
|
3118
3245
|
function getValue(event, multiple) {
|
|
@@ -3149,45 +3276,47 @@ function SelectWidget(_ref) {
|
|
|
3149
3276
|
var enumOptions = options.enumOptions,
|
|
3150
3277
|
enumDisabled = options.enumDisabled,
|
|
3151
3278
|
optEmptyVal = options.emptyValue;
|
|
3152
|
-
var emptyValue = multiple ? [] :
|
|
3153
|
-
var handleFocus =
|
|
3279
|
+
var emptyValue = multiple ? [] : '';
|
|
3280
|
+
var handleFocus = react.useCallback(function (event) {
|
|
3154
3281
|
var newValue = getValue(event, multiple);
|
|
3155
3282
|
return onFocus(id, utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3156
3283
|
}, [onFocus, id, schema, multiple, options]);
|
|
3157
|
-
var handleBlur =
|
|
3284
|
+
var handleBlur = react.useCallback(function (event) {
|
|
3158
3285
|
var newValue = getValue(event, multiple);
|
|
3159
3286
|
return onBlur(id, utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3160
3287
|
}, [onBlur, id, schema, multiple, options]);
|
|
3161
|
-
var handleChange =
|
|
3288
|
+
var handleChange = react.useCallback(function (event) {
|
|
3162
3289
|
var newValue = getValue(event, multiple);
|
|
3163
3290
|
return onChange(utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3164
3291
|
}, [onChange, schema, multiple, options]);
|
|
3165
3292
|
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
3166
|
-
return
|
|
3293
|
+
return jsxRuntime.jsxs("select", {
|
|
3167
3294
|
id: id,
|
|
3168
3295
|
name: id,
|
|
3169
3296
|
multiple: multiple,
|
|
3170
|
-
className:
|
|
3171
|
-
value: typeof selectedIndexes ===
|
|
3297
|
+
className: 'form-control',
|
|
3298
|
+
value: typeof selectedIndexes === 'undefined' ? emptyValue : selectedIndexes,
|
|
3172
3299
|
required: required,
|
|
3173
3300
|
disabled: disabled || readonly,
|
|
3174
3301
|
autoFocus: autofocus,
|
|
3175
3302
|
onBlur: handleBlur,
|
|
3176
3303
|
onFocus: handleFocus,
|
|
3177
3304
|
onChange: handleChange,
|
|
3178
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3305
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
3306
|
+
children: [!multiple && schema["default"] === undefined && jsxRuntime.jsx("option", {
|
|
3307
|
+
value: '',
|
|
3308
|
+
children: placeholder
|
|
3309
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
3310
|
+
var value = _ref2.value,
|
|
3311
|
+
label = _ref2.label;
|
|
3312
|
+
var disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
|
|
3313
|
+
return jsxRuntime.jsx("option", {
|
|
3314
|
+
value: String(i),
|
|
3315
|
+
disabled: disabled,
|
|
3316
|
+
children: label
|
|
3317
|
+
}, i);
|
|
3318
|
+
})]
|
|
3319
|
+
});
|
|
3191
3320
|
}
|
|
3192
3321
|
|
|
3193
3322
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -3208,23 +3337,23 @@ function TextareaWidget(_ref) {
|
|
|
3208
3337
|
onChange = _ref.onChange,
|
|
3209
3338
|
onBlur = _ref.onBlur,
|
|
3210
3339
|
onFocus = _ref.onFocus;
|
|
3211
|
-
var handleChange =
|
|
3340
|
+
var handleChange = react.useCallback(function (_ref2) {
|
|
3212
3341
|
var value = _ref2.target.value;
|
|
3213
|
-
return onChange(value ===
|
|
3342
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
3214
3343
|
}, [onChange, options.emptyValue]);
|
|
3215
|
-
var handleBlur =
|
|
3344
|
+
var handleBlur = react.useCallback(function (_ref3) {
|
|
3216
3345
|
var value = _ref3.target.value;
|
|
3217
3346
|
return onBlur(id, value);
|
|
3218
3347
|
}, [onBlur, id]);
|
|
3219
|
-
var handleFocus =
|
|
3348
|
+
var handleFocus = react.useCallback(function (_ref4) {
|
|
3220
3349
|
var value = _ref4.target.value;
|
|
3221
3350
|
return onFocus(id, value);
|
|
3222
3351
|
}, [id, onFocus]);
|
|
3223
|
-
return
|
|
3352
|
+
return jsxRuntime.jsx("textarea", {
|
|
3224
3353
|
id: id,
|
|
3225
3354
|
name: id,
|
|
3226
|
-
className:
|
|
3227
|
-
value: value ? value :
|
|
3355
|
+
className: 'form-control',
|
|
3356
|
+
value: value ? value : '',
|
|
3228
3357
|
placeholder: placeholder,
|
|
3229
3358
|
required: required,
|
|
3230
3359
|
disabled: disabled,
|
|
@@ -3249,8 +3378,8 @@ TextareaWidget.defaultProps = {
|
|
|
3249
3378
|
function TextWidget(props) {
|
|
3250
3379
|
var options = props.options,
|
|
3251
3380
|
registry = props.registry;
|
|
3252
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3253
|
-
return
|
|
3381
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3382
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({}, props));
|
|
3254
3383
|
}
|
|
3255
3384
|
|
|
3256
3385
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
@@ -3260,9 +3389,9 @@ function TextWidget(props) {
|
|
|
3260
3389
|
function URLWidget(props) {
|
|
3261
3390
|
var options = props.options,
|
|
3262
3391
|
registry = props.registry;
|
|
3263
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3264
|
-
return
|
|
3265
|
-
type:
|
|
3392
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3393
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3394
|
+
type: 'url'
|
|
3266
3395
|
}, props));
|
|
3267
3396
|
}
|
|
3268
3397
|
|
|
@@ -3273,9 +3402,9 @@ function URLWidget(props) {
|
|
|
3273
3402
|
function UpDownWidget(props) {
|
|
3274
3403
|
var options = props.options,
|
|
3275
3404
|
registry = props.registry;
|
|
3276
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3277
|
-
return
|
|
3278
|
-
type:
|
|
3405
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3406
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3407
|
+
type: 'number'
|
|
3279
3408
|
}, props));
|
|
3280
3409
|
}
|
|
3281
3410
|
|
|
@@ -3312,7 +3441,8 @@ function getDefaultRegistry() {
|
|
|
3312
3441
|
templates: templates(),
|
|
3313
3442
|
widgets: widgets(),
|
|
3314
3443
|
rootSchema: {},
|
|
3315
|
-
formContext: {}
|
|
3444
|
+
formContext: {},
|
|
3445
|
+
translateString: utils.englishStringTranslator
|
|
3316
3446
|
};
|
|
3317
3447
|
}
|
|
3318
3448
|
|
|
@@ -3335,7 +3465,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3335
3465
|
_this.formElement = void 0;
|
|
3336
3466
|
_this.getUsedFormData = function (formData, fields) {
|
|
3337
3467
|
// For the case of a single input form
|
|
3338
|
-
if (fields.length === 0 && typeof formData !==
|
|
3468
|
+
if (fields.length === 0 && typeof formData !== 'object') {
|
|
3339
3469
|
return formData;
|
|
3340
3470
|
}
|
|
3341
3471
|
// _pick has incorrect type definition, it works with string[][], because lodash/hasIn supports it
|
|
@@ -3356,22 +3486,22 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3356
3486
|
paths = [[]];
|
|
3357
3487
|
}
|
|
3358
3488
|
Object.keys(_obj).forEach(function (key) {
|
|
3359
|
-
if (typeof _obj[key] ===
|
|
3489
|
+
if (typeof _obj[key] === 'object') {
|
|
3360
3490
|
var newPaths = paths.map(function (path) {
|
|
3361
3491
|
return [].concat(path, [key]);
|
|
3362
3492
|
});
|
|
3363
3493
|
// If an object is marked with additionalProperties, all its keys are valid
|
|
3364
|
-
if (_obj[key][utils.RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][utils.NAME_KEY] !==
|
|
3494
|
+
if (_obj[key][utils.RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][utils.NAME_KEY] !== '') {
|
|
3365
3495
|
acc.push(_obj[key][utils.NAME_KEY]);
|
|
3366
3496
|
} else {
|
|
3367
3497
|
getAllPaths(_obj[key], acc, newPaths);
|
|
3368
3498
|
}
|
|
3369
|
-
} else if (key === utils.NAME_KEY && _obj[key] !==
|
|
3499
|
+
} else if (key === utils.NAME_KEY && _obj[key] !== '') {
|
|
3370
3500
|
paths.forEach(function (path) {
|
|
3371
3501
|
var formValue = get__default["default"](formData, path);
|
|
3372
3502
|
// adds path to fieldNames if it points to a value
|
|
3373
3503
|
// or an empty object/array
|
|
3374
|
-
if (typeof formValue !==
|
|
3504
|
+
if (typeof formValue !== 'object' || isEmpty__default["default"](formValue)) {
|
|
3375
3505
|
acc.push(path);
|
|
3376
3506
|
}
|
|
3377
3507
|
});
|
|
@@ -3404,7 +3534,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3404
3534
|
var newFormData = formData;
|
|
3405
3535
|
if (omitExtraData === true && liveOmit === true) {
|
|
3406
3536
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3407
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3537
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
3408
3538
|
var fieldNames = _this.getFieldNames(pathSchema, formData);
|
|
3409
3539
|
newFormData = _this.getUsedFormData(formData, fieldNames);
|
|
3410
3540
|
state = {
|
|
@@ -3430,7 +3560,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3430
3560
|
schemaValidationErrorSchema: schemaValidationErrorSchema
|
|
3431
3561
|
};
|
|
3432
3562
|
} else if (!noValidate && newErrorSchema) {
|
|
3433
|
-
var _errorSchema = extraErrors ? utils.mergeObjects(newErrorSchema, extraErrors,
|
|
3563
|
+
var _errorSchema = extraErrors ? utils.mergeObjects(newErrorSchema, extraErrors, 'preventDuplicates') : newErrorSchema;
|
|
3434
3564
|
state = {
|
|
3435
3565
|
formData: newFormData,
|
|
3436
3566
|
errorSchema: _errorSchema,
|
|
@@ -3470,7 +3600,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3470
3600
|
schemaUtils = _this$state2.schemaUtils;
|
|
3471
3601
|
if (omitExtraData === true) {
|
|
3472
3602
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, newFormData);
|
|
3473
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3603
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', newFormData);
|
|
3474
3604
|
var fieldNames = _this.getFieldNames(pathSchema, newFormData);
|
|
3475
3605
|
newFormData = _this.getUsedFormData(newFormData, fieldNames);
|
|
3476
3606
|
}
|
|
@@ -3489,20 +3619,20 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3489
3619
|
if (onSubmit) {
|
|
3490
3620
|
onSubmit(_extends({}, _this.state, {
|
|
3491
3621
|
formData: newFormData,
|
|
3492
|
-
status:
|
|
3622
|
+
status: 'submitted'
|
|
3493
3623
|
}), event);
|
|
3494
3624
|
}
|
|
3495
3625
|
});
|
|
3496
3626
|
}
|
|
3497
3627
|
};
|
|
3498
3628
|
if (!props.validator) {
|
|
3499
|
-
throw new Error(
|
|
3629
|
+
throw new Error('A validator is required for Form functionality to work');
|
|
3500
3630
|
}
|
|
3501
3631
|
_this.state = _this.getStateFromProps(props, props.formData);
|
|
3502
3632
|
if (_this.props.onChange && !utils.deepEquals(_this.state.formData, _this.props.formData)) {
|
|
3503
3633
|
_this.props.onChange(_this.state);
|
|
3504
3634
|
}
|
|
3505
|
-
_this.formElement = /*#__PURE__*/
|
|
3635
|
+
_this.formElement = /*#__PURE__*/react.createRef();
|
|
3506
3636
|
return _this;
|
|
3507
3637
|
}
|
|
3508
3638
|
/** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
|
|
@@ -3529,10 +3659,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3529
3659
|
*/;
|
|
3530
3660
|
_proto.getStateFromProps = function getStateFromProps(props, inputFormData) {
|
|
3531
3661
|
var state = this.state || {};
|
|
3532
|
-
var schema =
|
|
3533
|
-
var uiSchema = (
|
|
3534
|
-
var edit = typeof inputFormData !==
|
|
3535
|
-
var liveValidate =
|
|
3662
|
+
var schema = 'schema' in props ? props.schema : this.props.schema;
|
|
3663
|
+
var uiSchema = ('uiSchema' in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
3664
|
+
var edit = typeof inputFormData !== 'undefined';
|
|
3665
|
+
var liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
3536
3666
|
var mustValidate = edit && !props.noValidate && liveValidate;
|
|
3537
3667
|
var rootSchema = schema;
|
|
3538
3668
|
var schemaUtils = state.schemaUtils;
|
|
@@ -3581,7 +3711,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3581
3711
|
errorSchema = merged.errorSchema;
|
|
3582
3712
|
errors = merged.errors;
|
|
3583
3713
|
}
|
|
3584
|
-
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema[
|
|
3714
|
+
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema['ui:rootFieldId'], formData, props.idPrefix, props.idSeparator);
|
|
3585
3715
|
var nextState = {
|
|
3586
3716
|
schemaUtils: schemaUtils,
|
|
3587
3717
|
schema: schema,
|
|
@@ -3633,14 +3763,15 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3633
3763
|
uiSchema = _this$state3.uiSchema;
|
|
3634
3764
|
var formContext = this.props.formContext;
|
|
3635
3765
|
var options = utils.getUiOptions(uiSchema);
|
|
3636
|
-
var ErrorListTemplate = utils.getTemplate(
|
|
3766
|
+
var ErrorListTemplate = utils.getTemplate('ErrorListTemplate', registry, options);
|
|
3637
3767
|
if (errors && errors.length) {
|
|
3638
|
-
return
|
|
3768
|
+
return jsxRuntime.jsx(ErrorListTemplate, {
|
|
3639
3769
|
errors: errors,
|
|
3640
3770
|
errorSchema: errorSchema || {},
|
|
3641
3771
|
schema: schema,
|
|
3642
3772
|
uiSchema: uiSchema,
|
|
3643
|
-
formContext: formContext
|
|
3773
|
+
formContext: formContext,
|
|
3774
|
+
registry: registry
|
|
3644
3775
|
});
|
|
3645
3776
|
}
|
|
3646
3777
|
return null;
|
|
@@ -3653,12 +3784,14 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3653
3784
|
/** Returns the registry for the form */
|
|
3654
3785
|
_proto.getRegistry = function getRegistry() {
|
|
3655
3786
|
var _this$props$templates;
|
|
3787
|
+
var customTranslateString = this.props.translateString;
|
|
3656
3788
|
var schemaUtils = this.state.schemaUtils;
|
|
3657
3789
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3658
3790
|
fields = _getDefaultRegistry.fields,
|
|
3659
3791
|
templates = _getDefaultRegistry.templates,
|
|
3660
3792
|
widgets = _getDefaultRegistry.widgets,
|
|
3661
|
-
formContext = _getDefaultRegistry.formContext
|
|
3793
|
+
formContext = _getDefaultRegistry.formContext,
|
|
3794
|
+
translateString = _getDefaultRegistry.translateString;
|
|
3662
3795
|
return {
|
|
3663
3796
|
fields: _extends({}, fields, this.props.fields),
|
|
3664
3797
|
templates: _extends({}, templates, this.props.templates, {
|
|
@@ -3667,13 +3800,14 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3667
3800
|
widgets: _extends({}, widgets, this.props.widgets),
|
|
3668
3801
|
rootSchema: this.props.schema,
|
|
3669
3802
|
formContext: this.props.formContext || formContext,
|
|
3670
|
-
schemaUtils: schemaUtils
|
|
3803
|
+
schemaUtils: schemaUtils,
|
|
3804
|
+
translateString: customTranslateString || translateString
|
|
3671
3805
|
};
|
|
3672
3806
|
}
|
|
3673
3807
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
3674
3808
|
_proto.submit = function submit() {
|
|
3675
3809
|
if (this.formElement.current) {
|
|
3676
|
-
this.formElement.current.dispatchEvent(new CustomEvent(
|
|
3810
|
+
this.formElement.current.dispatchEvent(new CustomEvent('submit', {
|
|
3677
3811
|
cancelable: true
|
|
3678
3812
|
}));
|
|
3679
3813
|
this.formElement.current.requestSubmit();
|
|
@@ -3688,12 +3822,12 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3688
3822
|
_proto.focusOnError = function focusOnError(error) {
|
|
3689
3823
|
var _this$props4 = this.props,
|
|
3690
3824
|
_this$props4$idPrefix = _this$props4.idPrefix,
|
|
3691
|
-
idPrefix = _this$props4$idPrefix === void 0 ?
|
|
3825
|
+
idPrefix = _this$props4$idPrefix === void 0 ? 'root' : _this$props4$idPrefix,
|
|
3692
3826
|
_this$props4$idSepara = _this$props4.idSeparator,
|
|
3693
|
-
idSeparator = _this$props4$idSepara === void 0 ?
|
|
3827
|
+
idSeparator = _this$props4$idSepara === void 0 ? '_' : _this$props4$idSepara;
|
|
3694
3828
|
var property = error.property;
|
|
3695
3829
|
var path = _toPath__default["default"](property);
|
|
3696
|
-
if (path[0] ===
|
|
3830
|
+
if (path[0] === '') {
|
|
3697
3831
|
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3698
3832
|
path[0] = idPrefix;
|
|
3699
3833
|
} else {
|
|
@@ -3745,7 +3879,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3745
3879
|
if (onError) {
|
|
3746
3880
|
onError(errors);
|
|
3747
3881
|
} else {
|
|
3748
|
-
console.error(
|
|
3882
|
+
console.error('Form validation failed', errors);
|
|
3749
3883
|
}
|
|
3750
3884
|
});
|
|
3751
3885
|
return false;
|
|
@@ -3762,7 +3896,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3762
3896
|
idPrefix = _this$props6.idPrefix,
|
|
3763
3897
|
idSeparator = _this$props6.idSeparator,
|
|
3764
3898
|
_this$props6$classNam = _this$props6.className,
|
|
3765
|
-
className = _this$props6$classNam === void 0 ?
|
|
3899
|
+
className = _this$props6$classNam === void 0 ? '' : _this$props6$classNam,
|
|
3766
3900
|
tagName = _this$props6.tagName,
|
|
3767
3901
|
name = _this$props6.name,
|
|
3768
3902
|
method = _this$props6.method,
|
|
@@ -3779,7 +3913,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3779
3913
|
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
3780
3914
|
formContext = _this$props6.formContext,
|
|
3781
3915
|
_this$props6$showErro = _this$props6.showErrorList,
|
|
3782
|
-
showErrorList = _this$props6$showErro === void 0 ?
|
|
3916
|
+
showErrorList = _this$props6$showErro === void 0 ? 'top' : _this$props6$showErro,
|
|
3783
3917
|
_internalFormWrapper = _this$props6._internalFormWrapper;
|
|
3784
3918
|
var _this$state4 = this.state,
|
|
3785
3919
|
schema = _this$state4.schema,
|
|
@@ -3794,9 +3928,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3794
3928
|
// PropTypes.elementType to use for the inner tag, so we'll need to pass `tagName` along if it is provided.
|
|
3795
3929
|
// NOTE, the `as` prop is native to `semantic-ui` and is emulated in the `material-ui` theme
|
|
3796
3930
|
var as = _internalFormWrapper ? tagName : undefined;
|
|
3797
|
-
var FormTag = _internalFormWrapper || tagName ||
|
|
3798
|
-
return
|
|
3799
|
-
className: className ? className :
|
|
3931
|
+
var FormTag = _internalFormWrapper || tagName || 'form';
|
|
3932
|
+
return jsxRuntime.jsxs(FormTag, {
|
|
3933
|
+
className: className ? className : 'rjsf',
|
|
3800
3934
|
id: id,
|
|
3801
3935
|
name: name,
|
|
3802
3936
|
method: method,
|
|
@@ -3808,35 +3942,36 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3808
3942
|
noValidate: noHtml5Validate,
|
|
3809
3943
|
onSubmit: this.onSubmit,
|
|
3810
3944
|
as: as,
|
|
3811
|
-
ref: this.formElement
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3945
|
+
ref: this.formElement,
|
|
3946
|
+
children: [showErrorList === 'top' && this.renderErrors(registry), jsxRuntime.jsx(_SchemaField, {
|
|
3947
|
+
name: '',
|
|
3948
|
+
schema: schema,
|
|
3949
|
+
uiSchema: uiSchema,
|
|
3950
|
+
errorSchema: errorSchema,
|
|
3951
|
+
idSchema: idSchema,
|
|
3952
|
+
idPrefix: idPrefix,
|
|
3953
|
+
idSeparator: idSeparator,
|
|
3954
|
+
formContext: formContext,
|
|
3955
|
+
formData: formData,
|
|
3956
|
+
onChange: this.onChange,
|
|
3957
|
+
onBlur: this.onBlur,
|
|
3958
|
+
onFocus: this.onFocus,
|
|
3959
|
+
registry: registry,
|
|
3960
|
+
disabled: disabled,
|
|
3961
|
+
readonly: readonly
|
|
3962
|
+
}), children ? children : jsxRuntime.jsx(SubmitButton, {
|
|
3963
|
+
uiSchema: uiSchema,
|
|
3964
|
+
registry: registry
|
|
3965
|
+
}), showErrorList === 'bottom' && this.renderErrors(registry)]
|
|
3966
|
+
});
|
|
3832
3967
|
};
|
|
3833
3968
|
return Form;
|
|
3834
|
-
}(
|
|
3969
|
+
}(react.Component);
|
|
3835
3970
|
|
|
3836
3971
|
var _excluded = ["fields", "widgets", "templates"];
|
|
3837
3972
|
/** A Higher-Order component that creates a wrapper around a `Form` with the overrides from the `WithThemeProps` */
|
|
3838
3973
|
function withTheme(themeProps) {
|
|
3839
|
-
return /*#__PURE__*/
|
|
3974
|
+
return /*#__PURE__*/react.forwardRef(function (_ref, ref) {
|
|
3840
3975
|
var _themeProps$templates, _templates;
|
|
3841
3976
|
var fields = _ref.fields,
|
|
3842
3977
|
widgets = _ref.widgets,
|
|
@@ -3847,7 +3982,7 @@ function withTheme(themeProps) {
|
|
|
3847
3982
|
templates = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.templates, templates, {
|
|
3848
3983
|
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)
|
|
3849
3984
|
});
|
|
3850
|
-
return
|
|
3985
|
+
return jsxRuntime.jsx(Form, _extends({}, themeProps, directProps, {
|
|
3851
3986
|
fields: fields,
|
|
3852
3987
|
widgets: widgets,
|
|
3853
3988
|
templates: templates,
|