@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
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/toPath'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/omit'), require('lodash-es/has'), require('lodash-es/unset')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/toPath', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/omit', 'lodash-es/has', 'lodash-es/unset'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.React, global.utils, global.get, global.isEmpty, global._pick, global._toPath, global.isObject, global.set, global.nanoid, global.omit, global.has, global.unset));
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/toPath'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/omit'), require('lodash-es/has'), require('lodash-es/unset'), require('markdown-to-jsx')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/toPath', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/omit', 'lodash-es/has', 'lodash-es/unset', 'markdown-to-jsx'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.jsxRuntime, global.React, global.utils, global.get, global.isEmpty, global._pick, global._toPath, global.isObject, global.set, global.nanoid, global.omit, global.has, global.unset, global.Markdown));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, react, utils, get, isEmpty, _pick, _toPath, isObject, set, nanoid, omit, has, unset, Markdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
9
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
11
10
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
12
11
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
@@ -16,6 +15,7 @@
|
|
|
16
15
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
17
16
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
18
17
|
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
18
|
+
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
19
19
|
|
|
20
20
|
function _defineProperties(target, props) {
|
|
21
21
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
onChange = _this$props3.onChange,
|
|
196
196
|
errorSchema = _this$props3.errorSchema;
|
|
197
197
|
var newErrorSchema;
|
|
198
|
-
if (
|
|
198
|
+
if (errorSchema) {
|
|
199
199
|
newErrorSchema = {};
|
|
200
200
|
for (var idx in errorSchema) {
|
|
201
201
|
var i = parseInt(idx);
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
var newFormData = arrayData.map(function (item, i) {
|
|
237
237
|
// We need to treat undefined items as nulls to have validation.
|
|
238
238
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
239
|
-
var jsonValue = typeof value ===
|
|
239
|
+
var jsonValue = typeof value === 'undefined' ? null : value;
|
|
240
240
|
return index === i ? jsonValue : item;
|
|
241
241
|
});
|
|
242
242
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends2 = {}, _extends2[index] = newErrorSchema, _extends2)), id);
|
|
@@ -296,10 +296,10 @@
|
|
|
296
296
|
if (Array.isArray(itemSchema.type)) {
|
|
297
297
|
// While we don't yet support composite/nullable jsonschema types, it's
|
|
298
298
|
// future-proof to check for requirement against these.
|
|
299
|
-
return !itemSchema.type.includes(
|
|
299
|
+
return !itemSchema.type.includes('null');
|
|
300
300
|
}
|
|
301
301
|
// All non-null array item types are inherently required by design
|
|
302
|
-
return itemSchema.type !==
|
|
302
|
+
return itemSchema.type !== 'null';
|
|
303
303
|
}
|
|
304
304
|
/** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
|
|
305
305
|
* then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
|
|
@@ -372,14 +372,15 @@
|
|
|
372
372
|
uiSchema = _this$props7.uiSchema,
|
|
373
373
|
idSchema = _this$props7.idSchema,
|
|
374
374
|
registry = _this$props7.registry;
|
|
375
|
-
var schemaUtils = registry.schemaUtils
|
|
375
|
+
var schemaUtils = registry.schemaUtils,
|
|
376
|
+
translateString = registry.translateString;
|
|
376
377
|
if (!(utils.ITEMS_KEY in schema)) {
|
|
377
378
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
378
|
-
var UnsupportedFieldTemplate = utils.getTemplate(
|
|
379
|
-
return
|
|
379
|
+
var UnsupportedFieldTemplate = utils.getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
380
|
+
return jsxRuntime.jsx(UnsupportedFieldTemplate, {
|
|
380
381
|
schema: schema,
|
|
381
382
|
idSchema: idSchema,
|
|
382
|
-
reason:
|
|
383
|
+
reason: translateString(utils.TranslatableString.MissingItems),
|
|
383
384
|
registry: registry
|
|
384
385
|
});
|
|
385
386
|
}
|
|
@@ -422,7 +423,7 @@
|
|
|
422
423
|
onFocus = _this$props8.onFocus,
|
|
423
424
|
idPrefix = _this$props8.idPrefix,
|
|
424
425
|
_this$props8$idSepara = _this$props8.idSeparator,
|
|
425
|
-
idSeparator = _this$props8$idSepara === void 0 ?
|
|
426
|
+
idSeparator = _this$props8$idSepara === void 0 ? '_' : _this$props8$idSepara,
|
|
426
427
|
rawErrors = _this$props8.rawErrors;
|
|
427
428
|
var keyedFormData = this.state.keyedFormData;
|
|
428
429
|
var title = schema.title === undefined ? name : schema.title;
|
|
@@ -477,8 +478,8 @@
|
|
|
477
478
|
rawErrors: rawErrors,
|
|
478
479
|
registry: registry
|
|
479
480
|
};
|
|
480
|
-
var Template = utils.getTemplate(
|
|
481
|
-
return
|
|
481
|
+
var Template = utils.getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
482
|
+
return jsxRuntime.jsx(Template, _extends({}, arrayProps));
|
|
482
483
|
}
|
|
483
484
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
484
485
|
*/;
|
|
@@ -511,8 +512,9 @@
|
|
|
511
512
|
widget = _getUiOptions2.widget,
|
|
512
513
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
513
514
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
514
|
-
return
|
|
515
|
+
return jsxRuntime.jsx(Widget, {
|
|
515
516
|
id: idSchema.$id,
|
|
517
|
+
name: name,
|
|
516
518
|
multiple: true,
|
|
517
519
|
onChange: this.onSelectChange,
|
|
518
520
|
onBlur: onBlur,
|
|
@@ -564,11 +566,12 @@
|
|
|
564
566
|
var enumOptions = utils.optionsList(itemsSchema);
|
|
565
567
|
var _getUiOptions3 = utils.getUiOptions(uiSchema),
|
|
566
568
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
567
|
-
widget = _getUiOptions3$widget === void 0 ?
|
|
569
|
+
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
568
570
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
569
571
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
570
|
-
return
|
|
572
|
+
return jsxRuntime.jsx(Widget, {
|
|
571
573
|
id: idSchema.$id,
|
|
574
|
+
name: name,
|
|
572
575
|
multiple: true,
|
|
573
576
|
onChange: this.onSelectChange,
|
|
574
577
|
onBlur: onBlur,
|
|
@@ -617,12 +620,13 @@
|
|
|
617
620
|
formContext = registry.formContext;
|
|
618
621
|
var _getUiOptions4 = utils.getUiOptions(uiSchema),
|
|
619
622
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
620
|
-
widget = _getUiOptions4$widget === void 0 ?
|
|
623
|
+
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
621
624
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
622
625
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
623
|
-
return
|
|
626
|
+
return jsxRuntime.jsx(Widget, {
|
|
624
627
|
options: options,
|
|
625
628
|
id: idSchema.$id,
|
|
629
|
+
name: name,
|
|
626
630
|
multiple: true,
|
|
627
631
|
onChange: this.onSelectChange,
|
|
628
632
|
onBlur: onBlur,
|
|
@@ -638,7 +642,7 @@
|
|
|
638
642
|
formContext: formContext,
|
|
639
643
|
autofocus: autofocus,
|
|
640
644
|
rawErrors: rawErrors,
|
|
641
|
-
label:
|
|
645
|
+
label: ''
|
|
642
646
|
});
|
|
643
647
|
}
|
|
644
648
|
/** Renders an array that has a maximum limit of items
|
|
@@ -654,7 +658,7 @@
|
|
|
654
658
|
errorSchema = _this$props12.errorSchema,
|
|
655
659
|
idPrefix = _this$props12.idPrefix,
|
|
656
660
|
_this$props12$idSepar = _this$props12.idSeparator,
|
|
657
|
-
idSeparator = _this$props12$idSepar === void 0 ?
|
|
661
|
+
idSeparator = _this$props12$idSepar === void 0 ? '_' : _this$props12$idSepar,
|
|
658
662
|
idSchema = _this$props12.idSchema,
|
|
659
663
|
name = _this$props12.name,
|
|
660
664
|
_this$props12$disable = _this$props12.disabled,
|
|
@@ -690,7 +694,7 @@
|
|
|
690
694
|
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
691
695
|
var arrayProps = {
|
|
692
696
|
canAdd: canAdd,
|
|
693
|
-
className:
|
|
697
|
+
className: 'field field-array field-array-fixed-items',
|
|
694
698
|
disabled: disabled,
|
|
695
699
|
idSchema: idSchema,
|
|
696
700
|
formData: formData,
|
|
@@ -735,8 +739,8 @@
|
|
|
735
739
|
formContext: formContext,
|
|
736
740
|
rawErrors: rawErrors
|
|
737
741
|
};
|
|
738
|
-
var Template = utils.getTemplate(
|
|
739
|
-
return
|
|
742
|
+
var Template = utils.getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
743
|
+
return jsxRuntime.jsx(Template, _extends({}, arrayProps));
|
|
740
744
|
}
|
|
741
745
|
/** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
|
|
742
746
|
* back to the `ArrayFieldItemTemplate`.
|
|
@@ -792,7 +796,7 @@
|
|
|
792
796
|
return has[key];
|
|
793
797
|
});
|
|
794
798
|
return {
|
|
795
|
-
children:
|
|
799
|
+
children: jsxRuntime.jsx(ItemSchemaField, {
|
|
796
800
|
name: name,
|
|
797
801
|
index: index,
|
|
798
802
|
schema: itemSchema,
|
|
@@ -814,7 +818,7 @@
|
|
|
814
818
|
autofocus: autofocus,
|
|
815
819
|
rawErrors: rawErrors
|
|
816
820
|
}),
|
|
817
|
-
className:
|
|
821
|
+
className: 'array-item',
|
|
818
822
|
disabled: disabled,
|
|
819
823
|
canAdd: canAdd,
|
|
820
824
|
hasToolbar: has.toolbar,
|
|
@@ -836,12 +840,15 @@
|
|
|
836
840
|
_createClass(ArrayField, [{
|
|
837
841
|
key: "itemTitle",
|
|
838
842
|
get: function get() {
|
|
839
|
-
var
|
|
840
|
-
|
|
843
|
+
var _this$props14 = this.props,
|
|
844
|
+
schema = _this$props14.schema,
|
|
845
|
+
registry = _this$props14.registry;
|
|
846
|
+
var translateString = registry.translateString;
|
|
847
|
+
return get__default["default"](schema, [utils.ITEMS_KEY, 'title'], get__default["default"](schema, [utils.ITEMS_KEY, 'description'], translateString(utils.TranslatableString.ArrayItemTitle)));
|
|
841
848
|
}
|
|
842
849
|
}]);
|
|
843
850
|
return ArrayField;
|
|
844
|
-
}(
|
|
851
|
+
}(react.Component);
|
|
845
852
|
|
|
846
853
|
var _excluded$8 = ["widget"];
|
|
847
854
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
@@ -866,19 +873,22 @@
|
|
|
866
873
|
rawErrors = props.rawErrors;
|
|
867
874
|
var title = schema.title;
|
|
868
875
|
var widgets = registry.widgets,
|
|
869
|
-
formContext = registry.formContext
|
|
876
|
+
formContext = registry.formContext,
|
|
877
|
+
translateString = registry.translateString;
|
|
870
878
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
871
879
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
872
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
880
|
+
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
873
881
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
874
882
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
883
|
+
var yes = translateString(utils.TranslatableString.YesLabel);
|
|
884
|
+
var no = translateString(utils.TranslatableString.NoLabel);
|
|
875
885
|
var enumOptions;
|
|
876
886
|
if (Array.isArray(schema.oneOf)) {
|
|
877
887
|
enumOptions = utils.optionsList({
|
|
878
888
|
oneOf: schema.oneOf.map(function (option) {
|
|
879
889
|
if (isObject__default["default"](option)) {
|
|
880
890
|
return _extends({}, option, {
|
|
881
|
-
title: option.title || (option["const"] === true ?
|
|
891
|
+
title: option.title || (option["const"] === true ? yes : no)
|
|
882
892
|
});
|
|
883
893
|
}
|
|
884
894
|
return undefined;
|
|
@@ -892,14 +902,14 @@
|
|
|
892
902
|
var schemaWithEnumNames = schema;
|
|
893
903
|
var enums = (_schema$enum = schema["enum"]) != null ? _schema$enum : [true, false];
|
|
894
904
|
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every(function (v) {
|
|
895
|
-
return typeof v ===
|
|
905
|
+
return typeof v === 'boolean';
|
|
896
906
|
})) {
|
|
897
907
|
enumOptions = [{
|
|
898
908
|
value: enums[0],
|
|
899
|
-
label: enums[0] ?
|
|
909
|
+
label: enums[0] ? yes : no
|
|
900
910
|
}, {
|
|
901
911
|
value: enums[1],
|
|
902
|
-
label: enums[1] ?
|
|
912
|
+
label: enums[1] ? yes : no
|
|
903
913
|
}];
|
|
904
914
|
} else {
|
|
905
915
|
enumOptions = utils.optionsList({
|
|
@@ -909,13 +919,14 @@
|
|
|
909
919
|
});
|
|
910
920
|
}
|
|
911
921
|
}
|
|
912
|
-
return
|
|
922
|
+
return jsxRuntime.jsx(Widget, {
|
|
913
923
|
options: _extends({}, options, {
|
|
914
924
|
enumOptions: enumOptions
|
|
915
925
|
}),
|
|
916
926
|
schema: schema,
|
|
917
927
|
uiSchema: uiSchema,
|
|
918
928
|
id: idSchema.$id,
|
|
929
|
+
name: name,
|
|
919
930
|
onChange: onChange,
|
|
920
931
|
onFocus: onFocus,
|
|
921
932
|
onBlur: onBlur,
|
|
@@ -932,9 +943,6 @@
|
|
|
932
943
|
}
|
|
933
944
|
|
|
934
945
|
var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"];
|
|
935
|
-
/** The prefix used when a oneOf option does not have a title
|
|
936
|
-
*/
|
|
937
|
-
var UNKNOWN_OPTION_PREFIX = "Option";
|
|
938
946
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
939
947
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
940
948
|
*
|
|
@@ -968,7 +976,7 @@
|
|
|
968
976
|
if (newFormData && newOption) {
|
|
969
977
|
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
970
978
|
// so that only the root objects themselves are created without adding undefined children properties
|
|
971
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData,
|
|
979
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
972
980
|
}
|
|
973
981
|
onChange(newFormData, undefined, _this.getFieldId());
|
|
974
982
|
_this.setState({
|
|
@@ -1055,12 +1063,13 @@
|
|
|
1055
1063
|
var _this$props4 = this.props,
|
|
1056
1064
|
idSchema = _this$props4.idSchema,
|
|
1057
1065
|
schema = _this$props4.schema;
|
|
1058
|
-
return "" + idSchema.$id + (schema.oneOf ?
|
|
1066
|
+
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1059
1067
|
}
|
|
1060
1068
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1061
1069
|
*/;
|
|
1062
1070
|
_proto.render = function render() {
|
|
1063
1071
|
var _this$props5 = this.props,
|
|
1072
|
+
name = _this$props5.name,
|
|
1064
1073
|
baseType = _this$props5.baseType,
|
|
1065
1074
|
_this$props5$disabled = _this$props5.disabled,
|
|
1066
1075
|
disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
|
|
@@ -1073,14 +1082,15 @@
|
|
|
1073
1082
|
schema = _this$props5.schema,
|
|
1074
1083
|
uiSchema = _this$props5.uiSchema;
|
|
1075
1084
|
var widgets = registry.widgets,
|
|
1076
|
-
fields = registry.fields
|
|
1085
|
+
fields = registry.fields,
|
|
1086
|
+
translateString = registry.translateString;
|
|
1077
1087
|
var _SchemaField = fields.SchemaField;
|
|
1078
1088
|
var _this$state2 = this.state,
|
|
1079
1089
|
selectedOption = _this$state2.selectedOption,
|
|
1080
1090
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1081
1091
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1082
1092
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1083
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
1093
|
+
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1084
1094
|
placeholder = _getUiOptions.placeholder,
|
|
1085
1095
|
autofocus = _getUiOptions.autofocus,
|
|
1086
1096
|
autocomplete = _getUiOptions.autocomplete,
|
|
@@ -1088,7 +1098,7 @@
|
|
|
1088
1098
|
title = _getUiOptions$title === void 0 ? schema.title : _getUiOptions$title,
|
|
1089
1099
|
uiOptions = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$7);
|
|
1090
1100
|
var Widget = utils.getWidget({
|
|
1091
|
-
type:
|
|
1101
|
+
type: 'number'
|
|
1092
1102
|
}, widget, widgets);
|
|
1093
1103
|
var rawErrors = get__default["default"](errorSchema, utils.ERRORS_KEY, []);
|
|
1094
1104
|
var fieldErrorSchema = omit__default["default"](errorSchema, [utils.ERRORS_KEY]);
|
|
@@ -1101,46 +1111,50 @@
|
|
|
1101
1111
|
type: baseType
|
|
1102
1112
|
});
|
|
1103
1113
|
}
|
|
1104
|
-
var
|
|
1114
|
+
var translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
|
|
1115
|
+
var translateParams = title ? [title] : [];
|
|
1105
1116
|
var enumOptions = retrievedOptions.map(function (opt, index) {
|
|
1106
1117
|
return {
|
|
1107
|
-
label: opt.title ||
|
|
1118
|
+
label: opt.title || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1108
1119
|
value: index
|
|
1109
1120
|
};
|
|
1110
1121
|
});
|
|
1111
|
-
return
|
|
1112
|
-
className:
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1122
|
+
return jsxRuntime.jsxs("div", {
|
|
1123
|
+
className: 'panel panel-default panel-body',
|
|
1124
|
+
children: [jsxRuntime.jsx("div", {
|
|
1125
|
+
className: 'form-group',
|
|
1126
|
+
children: jsxRuntime.jsx(Widget, {
|
|
1127
|
+
id: this.getFieldId(),
|
|
1128
|
+
name: "" + name + (schema.oneOf ? '__oneof_select' : '__anyof_select'),
|
|
1129
|
+
schema: {
|
|
1130
|
+
type: 'number',
|
|
1131
|
+
"default": 0
|
|
1132
|
+
},
|
|
1133
|
+
onChange: this.onOptionChange,
|
|
1134
|
+
onBlur: onBlur,
|
|
1135
|
+
onFocus: onFocus,
|
|
1136
|
+
disabled: disabled || isEmpty__default["default"](enumOptions),
|
|
1137
|
+
multiple: false,
|
|
1138
|
+
rawErrors: rawErrors,
|
|
1139
|
+
errorSchema: fieldErrorSchema,
|
|
1140
|
+
value: selectedOption >= 0 ? selectedOption : undefined,
|
|
1141
|
+
options: _extends({
|
|
1142
|
+
enumOptions: enumOptions
|
|
1143
|
+
}, uiOptions),
|
|
1144
|
+
registry: registry,
|
|
1145
|
+
formContext: formContext,
|
|
1146
|
+
placeholder: placeholder,
|
|
1147
|
+
autocomplete: autocomplete,
|
|
1148
|
+
autofocus: autofocus,
|
|
1149
|
+
label: ''
|
|
1150
|
+
})
|
|
1151
|
+
}), option !== null && jsxRuntime.jsx(_SchemaField, _extends({}, this.props, {
|
|
1152
|
+
schema: optionSchema
|
|
1153
|
+
}))]
|
|
1154
|
+
});
|
|
1141
1155
|
};
|
|
1142
1156
|
return AnyOfField;
|
|
1143
|
-
}(
|
|
1157
|
+
}(react.Component);
|
|
1144
1158
|
|
|
1145
1159
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
1146
1160
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
@@ -1174,7 +1188,7 @@
|
|
|
1174
1188
|
onChange = props.onChange,
|
|
1175
1189
|
formData = props.formData,
|
|
1176
1190
|
initialValue = props.value;
|
|
1177
|
-
var _useState =
|
|
1191
|
+
var _useState = react.useState(initialValue),
|
|
1178
1192
|
lastValue = _useState[0],
|
|
1179
1193
|
setLastValue = _useState[1];
|
|
1180
1194
|
var StringField = registry.fields.StringField;
|
|
@@ -1183,32 +1197,32 @@
|
|
|
1183
1197
|
*
|
|
1184
1198
|
* @param value - The current value for the change occurring
|
|
1185
1199
|
*/
|
|
1186
|
-
var handleChange =
|
|
1200
|
+
var handleChange = react.useCallback(function (value) {
|
|
1187
1201
|
// Cache the original value in component state
|
|
1188
1202
|
setLastValue(value);
|
|
1189
1203
|
// Normalize decimals that don't start with a zero character in advance so
|
|
1190
1204
|
// that the rest of the normalization logic is simpler
|
|
1191
|
-
if (("" + value).charAt(0) ===
|
|
1205
|
+
if (("" + value).charAt(0) === '.') {
|
|
1192
1206
|
value = "0" + value;
|
|
1193
1207
|
}
|
|
1194
1208
|
// Check that the value is a string (this can happen if the widget used is a
|
|
1195
1209
|
// <select>, due to an enum declaration etc) then, if the value ends in a
|
|
1196
1210
|
// trailing decimal point or multiple zeroes, strip the trailing values
|
|
1197
|
-
var processed = typeof value ===
|
|
1211
|
+
var processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix) ? utils.asNumber(value.replace(trailingCharMatcher, '')) : utils.asNumber(value);
|
|
1198
1212
|
onChange(processed);
|
|
1199
1213
|
}, [onChange]);
|
|
1200
|
-
if (typeof lastValue ===
|
|
1214
|
+
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
1201
1215
|
// Construct a regular expression that checks for a string that consists
|
|
1202
1216
|
// of the formData value suffixed with zero or one '.' characters and zero
|
|
1203
1217
|
// or more '0' characters
|
|
1204
|
-
var re = new RegExp(("" + value).replace(
|
|
1218
|
+
var re = new RegExp(("" + value).replace('.', '\\.') + '\\.?0*$');
|
|
1205
1219
|
// If the cached "lastValue" is a match, use that instead of the formData
|
|
1206
1220
|
// value to prevent the input value from changing in the UI
|
|
1207
1221
|
if (lastValue.match(re)) {
|
|
1208
1222
|
value = lastValue;
|
|
1209
1223
|
}
|
|
1210
1224
|
}
|
|
1211
|
-
return
|
|
1225
|
+
return jsxRuntime.jsx(StringField, _extends({}, props, {
|
|
1212
1226
|
formData: value,
|
|
1213
1227
|
onChange: handleChange
|
|
1214
1228
|
}));
|
|
@@ -1249,7 +1263,7 @@
|
|
|
1249
1263
|
// fields which are "mandated" by the schema, these fields can
|
|
1250
1264
|
// be set to undefined by clicking a "delete field" button, so
|
|
1251
1265
|
// set empty values to the empty string.
|
|
1252
|
-
value =
|
|
1266
|
+
value = '';
|
|
1253
1267
|
}
|
|
1254
1268
|
var newFormData = _extends({}, formData, (_extends2 = {}, _extends2[name] = value, _extends2));
|
|
1255
1269
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends3 = {}, _extends3[name] = newErrorSchema, _extends3)), id);
|
|
@@ -1270,7 +1284,7 @@
|
|
|
1270
1284
|
var uiSchema = _this.props.uiSchema;
|
|
1271
1285
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1272
1286
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1273
|
-
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ?
|
|
1287
|
+
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1274
1288
|
var index = 0;
|
|
1275
1289
|
var newKey = preferredKey;
|
|
1276
1290
|
while (has__default["default"](formData, newKey)) {
|
|
@@ -1325,10 +1339,10 @@
|
|
|
1325
1339
|
type = apSchema.type;
|
|
1326
1340
|
}
|
|
1327
1341
|
if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
|
|
1328
|
-
type =
|
|
1342
|
+
type = 'object';
|
|
1329
1343
|
}
|
|
1330
1344
|
}
|
|
1331
|
-
var newKey = _this.getAvailableKey(
|
|
1345
|
+
var newKey = _this.getAvailableKey('newKey', newFormData);
|
|
1332
1346
|
// Cast this to make the `set` work properly
|
|
1333
1347
|
set__default["default"](newFormData, newKey, _this.getDefaultValue(type));
|
|
1334
1348
|
onChange(newFormData);
|
|
@@ -1359,22 +1373,22 @@
|
|
|
1359
1373
|
* @param type - The type of the new additional schema property
|
|
1360
1374
|
*/
|
|
1361
1375
|
_proto.getDefaultValue = function getDefaultValue(type) {
|
|
1376
|
+
var translateString = this.props.registry.translateString;
|
|
1362
1377
|
switch (type) {
|
|
1363
|
-
case
|
|
1364
|
-
return "New Value";
|
|
1365
|
-
case "array":
|
|
1378
|
+
case 'array':
|
|
1366
1379
|
return [];
|
|
1367
|
-
case
|
|
1380
|
+
case 'boolean':
|
|
1368
1381
|
return false;
|
|
1369
|
-
case
|
|
1382
|
+
case 'null':
|
|
1370
1383
|
return null;
|
|
1371
|
-
case
|
|
1384
|
+
case 'number':
|
|
1372
1385
|
return 0;
|
|
1373
|
-
case
|
|
1386
|
+
case 'object':
|
|
1374
1387
|
return {};
|
|
1388
|
+
case 'string':
|
|
1375
1389
|
default:
|
|
1376
1390
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1377
|
-
return
|
|
1391
|
+
return translateString(utils.TranslatableString.NewStringDefault);
|
|
1378
1392
|
}
|
|
1379
1393
|
}
|
|
1380
1394
|
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
@@ -1421,25 +1435,31 @@
|
|
|
1421
1435
|
var properties = Object.keys(schemaProperties);
|
|
1422
1436
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1423
1437
|
} catch (err) {
|
|
1424
|
-
return
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1438
|
+
return jsxRuntime.jsxs("div", {
|
|
1439
|
+
children: [jsxRuntime.jsxs("p", {
|
|
1440
|
+
className: 'config-error',
|
|
1441
|
+
style: {
|
|
1442
|
+
color: 'red'
|
|
1443
|
+
},
|
|
1444
|
+
children: ["Invalid ", name || 'root', " object field configuration:", jsxRuntime.jsx("em", {
|
|
1445
|
+
children: err.message
|
|
1446
|
+
}), "."]
|
|
1447
|
+
}), jsxRuntime.jsx("pre", {
|
|
1448
|
+
children: JSON.stringify(schema)
|
|
1449
|
+
})]
|
|
1450
|
+
});
|
|
1430
1451
|
}
|
|
1431
|
-
var Template = utils.getTemplate(
|
|
1452
|
+
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1432
1453
|
var templateProps = {
|
|
1433
1454
|
title: uiOptions.title || title,
|
|
1434
1455
|
description: description,
|
|
1435
1456
|
properties: orderedProperties.map(function (name) {
|
|
1436
1457
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
1437
1458
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
1438
|
-
var hidden = utils.getUiOptions(fieldUiSchema).widget ===
|
|
1459
|
+
var hidden = utils.getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
1439
1460
|
var fieldIdSchema = get__default["default"](idSchema, [name], {});
|
|
1440
1461
|
return {
|
|
1441
|
-
content:
|
|
1442
|
-
key: name,
|
|
1462
|
+
content: jsxRuntime.jsx(SchemaField, {
|
|
1443
1463
|
name: name,
|
|
1444
1464
|
required: _this2.isRequired(name),
|
|
1445
1465
|
schema: get__default["default"](schema, [utils.PROPERTIES_KEY, name], {}),
|
|
@@ -1460,7 +1480,7 @@
|
|
|
1460
1480
|
readonly: readonly,
|
|
1461
1481
|
hideError: hideError,
|
|
1462
1482
|
onDropPropertyClick: _this2.onDropPropertyClick
|
|
1463
|
-
}),
|
|
1483
|
+
}, name),
|
|
1464
1484
|
name: name,
|
|
1465
1485
|
readonly: readonly,
|
|
1466
1486
|
disabled: disabled,
|
|
@@ -1478,23 +1498,23 @@
|
|
|
1478
1498
|
formContext: formContext,
|
|
1479
1499
|
registry: registry
|
|
1480
1500
|
};
|
|
1481
|
-
return
|
|
1501
|
+
return jsxRuntime.jsx(Template, _extends({}, templateProps, {
|
|
1482
1502
|
onAddClick: this.handleAddClick
|
|
1483
1503
|
}));
|
|
1484
1504
|
};
|
|
1485
1505
|
return ObjectField;
|
|
1486
|
-
}(
|
|
1506
|
+
}(react.Component);
|
|
1487
1507
|
|
|
1488
1508
|
var _excluded$6 = ["__errors"];
|
|
1489
1509
|
/** The map of component type to FieldName */
|
|
1490
1510
|
var COMPONENT_TYPES = {
|
|
1491
|
-
array:
|
|
1492
|
-
"boolean":
|
|
1493
|
-
integer:
|
|
1494
|
-
number:
|
|
1495
|
-
object:
|
|
1496
|
-
string:
|
|
1497
|
-
"null":
|
|
1511
|
+
array: 'ArrayField',
|
|
1512
|
+
"boolean": 'BooleanField',
|
|
1513
|
+
integer: 'NumberField',
|
|
1514
|
+
number: 'NumberField',
|
|
1515
|
+
object: 'ObjectField',
|
|
1516
|
+
string: 'StringField',
|
|
1517
|
+
"null": 'NullField'
|
|
1498
1518
|
};
|
|
1499
1519
|
/** Computes and returns which `Field` implementation to return in order to render the field represented by the
|
|
1500
1520
|
* `schema`. The `uiOptions` are used to alter what potential `Field` implementation is actually returned. If no
|
|
@@ -1508,15 +1528,16 @@
|
|
|
1508
1528
|
*/
|
|
1509
1529
|
function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
1510
1530
|
var field = uiOptions.field;
|
|
1511
|
-
var fields = registry.fields
|
|
1512
|
-
|
|
1531
|
+
var fields = registry.fields,
|
|
1532
|
+
translateString = registry.translateString;
|
|
1533
|
+
if (typeof field === 'function') {
|
|
1513
1534
|
return field;
|
|
1514
1535
|
}
|
|
1515
|
-
if (typeof field ===
|
|
1536
|
+
if (typeof field === 'string' && field in fields) {
|
|
1516
1537
|
return fields[field];
|
|
1517
1538
|
}
|
|
1518
1539
|
var schemaType = utils.getSchemaType(schema);
|
|
1519
|
-
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType ||
|
|
1540
|
+
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
|
|
1520
1541
|
var componentName = COMPONENT_TYPES[type];
|
|
1521
1542
|
// If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
|
|
1522
1543
|
// render a field and let the MultiSchemaField component handle the form display
|
|
@@ -1526,11 +1547,11 @@
|
|
|
1526
1547
|
};
|
|
1527
1548
|
}
|
|
1528
1549
|
return componentName in fields ? fields[componentName] : function () {
|
|
1529
|
-
var UnsupportedFieldTemplate = utils.getTemplate(
|
|
1530
|
-
return
|
|
1550
|
+
var UnsupportedFieldTemplate = utils.getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
1551
|
+
return jsxRuntime.jsx(UnsupportedFieldTemplate, {
|
|
1531
1552
|
schema: schema,
|
|
1532
1553
|
idSchema: idSchema,
|
|
1533
|
-
reason:
|
|
1554
|
+
reason: translateString(utils.TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
1534
1555
|
registry: registry
|
|
1535
1556
|
});
|
|
1536
1557
|
};
|
|
@@ -1560,17 +1581,17 @@
|
|
|
1560
1581
|
var formContext = registry.formContext,
|
|
1561
1582
|
schemaUtils = registry.schemaUtils;
|
|
1562
1583
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1563
|
-
var FieldTemplate = utils.getTemplate(
|
|
1564
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
1565
|
-
var FieldHelpTemplate = utils.getTemplate(
|
|
1566
|
-
var FieldErrorTemplate = utils.getTemplate(
|
|
1584
|
+
var FieldTemplate = utils.getTemplate('FieldTemplate', registry, uiOptions);
|
|
1585
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1586
|
+
var FieldHelpTemplate = utils.getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
1587
|
+
var FieldErrorTemplate = utils.getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
1567
1588
|
var schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1568
1589
|
var fieldId = _idSchema[utils.ID_KEY];
|
|
1569
1590
|
var idSchema = utils.mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
1570
1591
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
1571
1592
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
1572
1593
|
*/
|
|
1573
|
-
var handleFieldComponentChange =
|
|
1594
|
+
var handleFieldComponentChange = react.useCallback(function (formData, newErrorSchema, id) {
|
|
1574
1595
|
var theId = id || fieldId;
|
|
1575
1596
|
return onChange(formData, newErrorSchema, theId);
|
|
1576
1597
|
}, [fieldId, onChange]);
|
|
@@ -1589,11 +1610,11 @@
|
|
|
1589
1610
|
__errors = _ref.__errors,
|
|
1590
1611
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1591
1612
|
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1592
|
-
var fieldUiSchema = omit__default["default"](uiSchema, [
|
|
1613
|
+
var fieldUiSchema = omit__default["default"](uiSchema, ['ui:classNames', 'classNames', 'ui:style']);
|
|
1593
1614
|
if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1594
|
-
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], [
|
|
1615
|
+
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
1595
1616
|
}
|
|
1596
|
-
var field =
|
|
1617
|
+
var field = jsxRuntime.jsx(FieldComponent, _extends({}, props, {
|
|
1597
1618
|
onChange: handleFieldComponentChange,
|
|
1598
1619
|
idSchema: idSchema,
|
|
1599
1620
|
schema: schema,
|
|
@@ -1614,12 +1635,12 @@
|
|
|
1614
1635
|
} else {
|
|
1615
1636
|
label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1616
1637
|
}
|
|
1617
|
-
var description = uiOptions.description || props.schema.description || schema.description ||
|
|
1638
|
+
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1618
1639
|
var help = uiOptions.help;
|
|
1619
|
-
var hidden = uiOptions.widget ===
|
|
1620
|
-
var classNames = [
|
|
1640
|
+
var hidden = uiOptions.widget === 'hidden';
|
|
1641
|
+
var classNames = ['form-group', 'field', "field-" + schema.type];
|
|
1621
1642
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1622
|
-
classNames.push(
|
|
1643
|
+
classNames.push('field-error has-error has-danger');
|
|
1623
1644
|
}
|
|
1624
1645
|
if (uiSchema !== null && uiSchema !== void 0 && uiSchema.classNames) {
|
|
1625
1646
|
{
|
|
@@ -1630,7 +1651,7 @@
|
|
|
1630
1651
|
if (uiOptions.classNames) {
|
|
1631
1652
|
classNames.push(uiOptions.classNames);
|
|
1632
1653
|
}
|
|
1633
|
-
var helpComponent =
|
|
1654
|
+
var helpComponent = jsxRuntime.jsx(FieldHelpTemplate, {
|
|
1634
1655
|
help: help,
|
|
1635
1656
|
idSchema: idSchema,
|
|
1636
1657
|
schema: schema,
|
|
@@ -1638,7 +1659,7 @@
|
|
|
1638
1659
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
1639
1660
|
registry: registry
|
|
1640
1661
|
});
|
|
1641
|
-
var errorsComponent = hideError ? undefined :
|
|
1662
|
+
var errorsComponent = hideError ? undefined : jsxRuntime.jsx(FieldErrorTemplate, {
|
|
1642
1663
|
errors: __errors,
|
|
1643
1664
|
errorSchema: errorSchema,
|
|
1644
1665
|
idSchema: idSchema,
|
|
@@ -1647,7 +1668,7 @@
|
|
|
1647
1668
|
registry: registry
|
|
1648
1669
|
});
|
|
1649
1670
|
var fieldProps = {
|
|
1650
|
-
description:
|
|
1671
|
+
description: jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
1651
1672
|
id: utils.descriptionId(id),
|
|
1652
1673
|
description: description,
|
|
1653
1674
|
schema: schema,
|
|
@@ -1656,7 +1677,7 @@
|
|
|
1656
1677
|
}),
|
|
1657
1678
|
rawDescription: description,
|
|
1658
1679
|
help: helpComponent,
|
|
1659
|
-
rawHelp: typeof help ===
|
|
1680
|
+
rawHelp: typeof help === 'string' ? help : undefined,
|
|
1660
1681
|
errors: errorsComponent,
|
|
1661
1682
|
rawErrors: hideError ? undefined : __errors,
|
|
1662
1683
|
id: id,
|
|
@@ -1670,7 +1691,7 @@
|
|
|
1670
1691
|
readonly: readonly,
|
|
1671
1692
|
hideError: hideError,
|
|
1672
1693
|
displayLabel: displayLabel,
|
|
1673
|
-
classNames: classNames.join(
|
|
1694
|
+
classNames: classNames.join(' ').trim(),
|
|
1674
1695
|
style: uiOptions.style,
|
|
1675
1696
|
formContext: formContext,
|
|
1676
1697
|
formData: formData,
|
|
@@ -1680,68 +1701,72 @@
|
|
|
1680
1701
|
};
|
|
1681
1702
|
var _AnyOfField = registry.fields.AnyOfField;
|
|
1682
1703
|
var _OneOfField = registry.fields.OneOfField;
|
|
1683
|
-
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[
|
|
1684
|
-
return
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1704
|
+
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:field']) && (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:fieldReplacesAnyOrOneOf']) === true;
|
|
1705
|
+
return jsxRuntime.jsx(FieldTemplate, _extends({}, fieldProps, {
|
|
1706
|
+
children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1707
|
+
children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsxRuntime.jsx(_AnyOfField, {
|
|
1708
|
+
name: name,
|
|
1709
|
+
disabled: disabled,
|
|
1710
|
+
readonly: readonly,
|
|
1711
|
+
hideError: hideError,
|
|
1712
|
+
errorSchema: errorSchema,
|
|
1713
|
+
formData: formData,
|
|
1714
|
+
formContext: formContext,
|
|
1715
|
+
idPrefix: idPrefix,
|
|
1716
|
+
idSchema: idSchema,
|
|
1717
|
+
idSeparator: idSeparator,
|
|
1718
|
+
onBlur: props.onBlur,
|
|
1719
|
+
onChange: props.onChange,
|
|
1720
|
+
onFocus: props.onFocus,
|
|
1721
|
+
options: schema.anyOf.map(function (_schema) {
|
|
1722
|
+
return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
|
|
1723
|
+
}),
|
|
1724
|
+
baseType: schema.type,
|
|
1725
|
+
registry: registry,
|
|
1726
|
+
schema: schema,
|
|
1727
|
+
uiSchema: uiSchema
|
|
1728
|
+
}), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsxRuntime.jsx(_OneOfField, {
|
|
1729
|
+
name: name,
|
|
1730
|
+
disabled: disabled,
|
|
1731
|
+
readonly: readonly,
|
|
1732
|
+
hideError: hideError,
|
|
1733
|
+
errorSchema: errorSchema,
|
|
1734
|
+
formData: formData,
|
|
1735
|
+
formContext: formContext,
|
|
1736
|
+
idPrefix: idPrefix,
|
|
1737
|
+
idSchema: idSchema,
|
|
1738
|
+
idSeparator: idSeparator,
|
|
1739
|
+
onBlur: props.onBlur,
|
|
1740
|
+
onChange: props.onChange,
|
|
1741
|
+
onFocus: props.onFocus,
|
|
1742
|
+
options: schema.oneOf.map(function (_schema) {
|
|
1743
|
+
return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
|
|
1744
|
+
}),
|
|
1745
|
+
baseType: schema.type,
|
|
1746
|
+
registry: registry,
|
|
1747
|
+
schema: schema,
|
|
1748
|
+
uiSchema: uiSchema
|
|
1749
|
+
})]
|
|
1750
|
+
})
|
|
1751
|
+
}));
|
|
1727
1752
|
}
|
|
1728
1753
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
1729
1754
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
1730
1755
|
*/
|
|
1731
|
-
var SchemaField = /*#__PURE__*/function (
|
|
1732
|
-
_inheritsLoose(SchemaField,
|
|
1756
|
+
var SchemaField = /*#__PURE__*/function (_Component) {
|
|
1757
|
+
_inheritsLoose(SchemaField, _Component);
|
|
1733
1758
|
function SchemaField() {
|
|
1734
|
-
return
|
|
1759
|
+
return _Component.apply(this, arguments) || this;
|
|
1735
1760
|
}
|
|
1736
1761
|
var _proto = SchemaField.prototype;
|
|
1737
1762
|
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
1738
1763
|
return !utils.deepEquals(this.props, nextProps);
|
|
1739
1764
|
};
|
|
1740
1765
|
_proto.render = function render() {
|
|
1741
|
-
return
|
|
1766
|
+
return jsxRuntime.jsx(SchemaFieldRender, _extends({}, this.props));
|
|
1742
1767
|
};
|
|
1743
1768
|
return SchemaField;
|
|
1744
|
-
}(
|
|
1769
|
+
}(react.Component);
|
|
1745
1770
|
|
|
1746
1771
|
var _excluded$5 = ["widget", "placeholder"];
|
|
1747
1772
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
@@ -1772,7 +1797,7 @@
|
|
|
1772
1797
|
formContext = registry.formContext,
|
|
1773
1798
|
schemaUtils = registry.schemaUtils;
|
|
1774
1799
|
var enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : undefined;
|
|
1775
|
-
var defaultWidget = enumOptions ?
|
|
1800
|
+
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1776
1801
|
if (format && utils.hasWidget(schema, format, widgets)) {
|
|
1777
1802
|
defaultWidget = format;
|
|
1778
1803
|
}
|
|
@@ -1780,16 +1805,17 @@
|
|
|
1780
1805
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1781
1806
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1782
1807
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1783
|
-
placeholder = _getUiOptions$placeho === void 0 ?
|
|
1808
|
+
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1784
1809
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1785
1810
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
1786
|
-
return
|
|
1811
|
+
return jsxRuntime.jsx(Widget, {
|
|
1787
1812
|
options: _extends({}, options, {
|
|
1788
1813
|
enumOptions: enumOptions
|
|
1789
1814
|
}),
|
|
1790
1815
|
schema: schema,
|
|
1791
1816
|
uiSchema: uiSchema,
|
|
1792
1817
|
id: idSchema.$id,
|
|
1818
|
+
name: name,
|
|
1793
1819
|
label: title === undefined ? name : title,
|
|
1794
1820
|
value: formData,
|
|
1795
1821
|
onChange: onChange,
|
|
@@ -1814,7 +1840,7 @@
|
|
|
1814
1840
|
function NullField(props) {
|
|
1815
1841
|
var formData = props.formData,
|
|
1816
1842
|
onChange = props.onChange;
|
|
1817
|
-
|
|
1843
|
+
react.useEffect(function () {
|
|
1818
1844
|
if (formData === undefined) {
|
|
1819
1845
|
onChange(null);
|
|
1820
1846
|
}
|
|
@@ -1854,8 +1880,8 @@
|
|
|
1854
1880
|
if (!description || !displayLabel) {
|
|
1855
1881
|
return null;
|
|
1856
1882
|
}
|
|
1857
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
1858
|
-
return
|
|
1883
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
1884
|
+
return jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
1859
1885
|
id: utils.descriptionId(idSchema),
|
|
1860
1886
|
description: description,
|
|
1861
1887
|
schema: schema,
|
|
@@ -1890,39 +1916,43 @@
|
|
|
1890
1916
|
flex: 1,
|
|
1891
1917
|
paddingLeft: 6,
|
|
1892
1918
|
paddingRight: 6,
|
|
1893
|
-
fontWeight:
|
|
1919
|
+
fontWeight: 'bold'
|
|
1894
1920
|
};
|
|
1895
|
-
return
|
|
1896
|
-
className: className
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1921
|
+
return jsxRuntime.jsxs("div", {
|
|
1922
|
+
className: className,
|
|
1923
|
+
children: [jsxRuntime.jsx("div", {
|
|
1924
|
+
className: hasToolbar ? 'col-xs-9' : 'col-xs-12',
|
|
1925
|
+
children: children
|
|
1926
|
+
}), hasToolbar && jsxRuntime.jsx("div", {
|
|
1927
|
+
className: 'col-xs-3 array-item-toolbox',
|
|
1928
|
+
children: jsxRuntime.jsxs("div", {
|
|
1929
|
+
className: 'btn-group',
|
|
1930
|
+
style: {
|
|
1931
|
+
display: 'flex',
|
|
1932
|
+
justifyContent: 'space-around'
|
|
1933
|
+
},
|
|
1934
|
+
children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
|
|
1935
|
+
style: btnStyle,
|
|
1936
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
1937
|
+
onClick: onReorderClick(index, index - 1),
|
|
1938
|
+
uiSchema: uiSchema,
|
|
1939
|
+
registry: registry
|
|
1940
|
+
}), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
|
|
1941
|
+
style: btnStyle,
|
|
1942
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
1943
|
+
onClick: onReorderClick(index, index + 1),
|
|
1944
|
+
uiSchema: uiSchema,
|
|
1945
|
+
registry: registry
|
|
1946
|
+
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
1947
|
+
style: btnStyle,
|
|
1948
|
+
disabled: disabled || readonly,
|
|
1949
|
+
onClick: onDropIndexClick(index),
|
|
1950
|
+
uiSchema: uiSchema,
|
|
1951
|
+
registry: registry
|
|
1952
|
+
})]
|
|
1953
|
+
})
|
|
1954
|
+
})]
|
|
1955
|
+
});
|
|
1926
1956
|
}
|
|
1927
1957
|
|
|
1928
1958
|
var _excluded$4 = ["key"];
|
|
@@ -1944,42 +1974,42 @@
|
|
|
1944
1974
|
schema = props.schema,
|
|
1945
1975
|
title = props.title;
|
|
1946
1976
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1947
|
-
var ArrayFieldDescriptionTemplate = utils.getTemplate(
|
|
1948
|
-
var ArrayFieldItemTemplate = utils.getTemplate(
|
|
1949
|
-
var ArrayFieldTitleTemplate = utils.getTemplate(
|
|
1977
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
1978
|
+
var ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
1979
|
+
var ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
1950
1980
|
// Button templates are not overridden in the uiSchema
|
|
1951
1981
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
1952
|
-
return
|
|
1982
|
+
return jsxRuntime.jsxs("fieldset", {
|
|
1953
1983
|
className: className,
|
|
1954
|
-
id: idSchema.$id
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
},
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
})
|
|
1984
|
+
id: idSchema.$id,
|
|
1985
|
+
children: [jsxRuntime.jsx(ArrayFieldTitleTemplate, {
|
|
1986
|
+
idSchema: idSchema,
|
|
1987
|
+
title: uiOptions.title || title,
|
|
1988
|
+
required: required,
|
|
1989
|
+
schema: schema,
|
|
1990
|
+
uiSchema: uiSchema,
|
|
1991
|
+
registry: registry
|
|
1992
|
+
}), jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
|
|
1993
|
+
idSchema: idSchema,
|
|
1994
|
+
description: uiOptions.description || schema.description,
|
|
1995
|
+
schema: schema,
|
|
1996
|
+
uiSchema: uiSchema,
|
|
1997
|
+
registry: registry
|
|
1998
|
+
}), jsxRuntime.jsx("div", {
|
|
1999
|
+
className: 'row array-item-list',
|
|
2000
|
+
children: items && items.map(function (_ref) {
|
|
2001
|
+
var key = _ref.key,
|
|
2002
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
2003
|
+
return jsxRuntime.jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
2004
|
+
})
|
|
2005
|
+
}), canAdd && jsxRuntime.jsx(AddButton, {
|
|
2006
|
+
className: 'array-item-add',
|
|
2007
|
+
onClick: onAddClick,
|
|
2008
|
+
disabled: disabled || readonly,
|
|
2009
|
+
uiSchema: uiSchema,
|
|
2010
|
+
registry: registry
|
|
2011
|
+
})]
|
|
2012
|
+
});
|
|
1983
2013
|
}
|
|
1984
2014
|
|
|
1985
2015
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
@@ -2000,8 +2030,8 @@
|
|
|
2000
2030
|
if (!title || !displayLabel) {
|
|
2001
2031
|
return null;
|
|
2002
2032
|
}
|
|
2003
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
2004
|
-
return
|
|
2033
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
2034
|
+
return jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2005
2035
|
id: utils.titleId(idSchema),
|
|
2006
2036
|
title: title,
|
|
2007
2037
|
required: required,
|
|
@@ -2011,7 +2041,7 @@
|
|
|
2011
2041
|
});
|
|
2012
2042
|
}
|
|
2013
2043
|
|
|
2014
|
-
var _excluded$3 = ["id", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2044
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2015
2045
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2016
2046
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2017
2047
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2027,6 +2057,7 @@
|
|
|
2027
2057
|
onBlur = props.onBlur,
|
|
2028
2058
|
onFocus = props.onFocus,
|
|
2029
2059
|
onChange = props.onChange,
|
|
2060
|
+
onChangeOverride = props.onChangeOverride,
|
|
2030
2061
|
options = props.options,
|
|
2031
2062
|
schema = props.schema,
|
|
2032
2063
|
type = props.type,
|
|
@@ -2034,51 +2065,52 @@
|
|
|
2034
2065
|
// Note: since React 15.2.0 we can't forward unknown element attributes, so we
|
|
2035
2066
|
// exclude the "options" and "schema" ones here.
|
|
2036
2067
|
if (!id) {
|
|
2037
|
-
console.log(
|
|
2068
|
+
console.log('No id for', props);
|
|
2038
2069
|
throw new Error("no id for props " + JSON.stringify(props));
|
|
2039
2070
|
}
|
|
2040
2071
|
var inputProps = _extends({}, rest, utils.getInputProps(schema, type, options));
|
|
2041
2072
|
var inputValue;
|
|
2042
|
-
if (inputProps.type ===
|
|
2043
|
-
inputValue = value || value === 0 ? value :
|
|
2073
|
+
if (inputProps.type === 'number' || inputProps.type === 'integer') {
|
|
2074
|
+
inputValue = value || value === 0 ? value : '';
|
|
2044
2075
|
} else {
|
|
2045
|
-
inputValue = value == null ?
|
|
2076
|
+
inputValue = value == null ? '' : value;
|
|
2046
2077
|
}
|
|
2047
|
-
var _onChange =
|
|
2078
|
+
var _onChange = react.useCallback(function (_ref) {
|
|
2048
2079
|
var value = _ref.target.value;
|
|
2049
|
-
return onChange(value ===
|
|
2080
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
2050
2081
|
}, [onChange, options]);
|
|
2051
|
-
var _onBlur =
|
|
2082
|
+
var _onBlur = react.useCallback(function (_ref2) {
|
|
2052
2083
|
var value = _ref2.target.value;
|
|
2053
2084
|
return onBlur(id, value);
|
|
2054
2085
|
}, [onBlur, id]);
|
|
2055
|
-
var _onFocus =
|
|
2086
|
+
var _onFocus = react.useCallback(function (_ref3) {
|
|
2056
2087
|
var value = _ref3.target.value;
|
|
2057
2088
|
return onFocus(id, value);
|
|
2058
2089
|
}, [onFocus, id]);
|
|
2059
|
-
return
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2090
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2091
|
+
children: [jsxRuntime.jsx("input", _extends({
|
|
2092
|
+
id: id,
|
|
2093
|
+
name: id,
|
|
2094
|
+
className: 'form-control',
|
|
2095
|
+
readOnly: readonly,
|
|
2096
|
+
disabled: disabled,
|
|
2097
|
+
autoFocus: autofocus,
|
|
2098
|
+
value: inputValue
|
|
2099
|
+
}, inputProps, {
|
|
2100
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
2101
|
+
onChange: onChangeOverride || _onChange,
|
|
2102
|
+
onBlur: _onBlur,
|
|
2103
|
+
onFocus: _onFocus,
|
|
2104
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
2105
|
+
})), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
|
|
2106
|
+
id: utils.examplesId(id),
|
|
2107
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
2108
|
+
return jsxRuntime.jsx("option", {
|
|
2109
|
+
value: example
|
|
2110
|
+
}, example);
|
|
2111
|
+
})
|
|
2112
|
+
}, "datalist_" + id)]
|
|
2113
|
+
});
|
|
2082
2114
|
}
|
|
2083
2115
|
|
|
2084
2116
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -2093,50 +2125,58 @@
|
|
|
2093
2125
|
if (norender) {
|
|
2094
2126
|
return null;
|
|
2095
2127
|
}
|
|
2096
|
-
return
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2128
|
+
return jsxRuntime.jsx("div", {
|
|
2129
|
+
children: jsxRuntime.jsx("button", _extends({
|
|
2130
|
+
type: 'submit'
|
|
2131
|
+
}, submitButtonProps, {
|
|
2132
|
+
className: "btn btn-info " + submitButtonProps.className,
|
|
2133
|
+
children: submitText
|
|
2134
|
+
}))
|
|
2135
|
+
});
|
|
2101
2136
|
}
|
|
2102
2137
|
|
|
2103
2138
|
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2104
2139
|
function IconButton(props) {
|
|
2105
2140
|
var _props$iconType = props.iconType,
|
|
2106
|
-
iconType = _props$iconType === void 0 ?
|
|
2141
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
2107
2142
|
icon = props.icon,
|
|
2108
2143
|
className = props.className,
|
|
2109
2144
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
2110
|
-
return
|
|
2111
|
-
type:
|
|
2145
|
+
return jsxRuntime.jsx("button", _extends({
|
|
2146
|
+
type: 'button',
|
|
2112
2147
|
className: "btn btn-" + iconType + " " + className
|
|
2113
|
-
}, otherProps
|
|
2114
|
-
|
|
2148
|
+
}, otherProps, {
|
|
2149
|
+
children: jsxRuntime.jsx("i", {
|
|
2150
|
+
className: "glyphicon glyphicon-" + icon
|
|
2151
|
+
})
|
|
2115
2152
|
}));
|
|
2116
2153
|
}
|
|
2117
2154
|
function MoveDownButton(props) {
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2155
|
+
var translateString = props.registry.translateString;
|
|
2156
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2157
|
+
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
2158
|
+
className: 'array-item-move-down'
|
|
2121
2159
|
}, props, {
|
|
2122
|
-
icon:
|
|
2160
|
+
icon: 'arrow-down'
|
|
2123
2161
|
}));
|
|
2124
2162
|
}
|
|
2125
2163
|
function MoveUpButton(props) {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2164
|
+
var translateString = props.registry.translateString;
|
|
2165
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2166
|
+
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
2167
|
+
className: 'array-item-move-up'
|
|
2129
2168
|
}, props, {
|
|
2130
|
-
icon:
|
|
2169
|
+
icon: 'arrow-up'
|
|
2131
2170
|
}));
|
|
2132
2171
|
}
|
|
2133
2172
|
function RemoveButton(props) {
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2173
|
+
var translateString = props.registry.translateString;
|
|
2174
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2175
|
+
title: translateString(utils.TranslatableString.RemoveButton),
|
|
2176
|
+
className: 'array-item-remove'
|
|
2137
2177
|
}, props, {
|
|
2138
|
-
iconType:
|
|
2139
|
-
icon:
|
|
2178
|
+
iconType: 'danger',
|
|
2179
|
+
icon: 'remove'
|
|
2140
2180
|
}));
|
|
2141
2181
|
}
|
|
2142
2182
|
|
|
@@ -2147,19 +2187,22 @@
|
|
|
2147
2187
|
onClick = _ref.onClick,
|
|
2148
2188
|
disabled = _ref.disabled,
|
|
2149
2189
|
registry = _ref.registry;
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2190
|
+
var translateString = registry.translateString;
|
|
2191
|
+
return jsxRuntime.jsx("div", {
|
|
2192
|
+
className: 'row',
|
|
2193
|
+
children: jsxRuntime.jsx("p", {
|
|
2194
|
+
className: "col-xs-3 col-xs-offset-9 text-right " + className,
|
|
2195
|
+
children: jsxRuntime.jsx(IconButton, {
|
|
2196
|
+
iconType: 'info',
|
|
2197
|
+
icon: 'plus',
|
|
2198
|
+
className: 'btn-add col-xs-12',
|
|
2199
|
+
title: translateString(utils.TranslatableString.AddButton),
|
|
2200
|
+
onClick: onClick,
|
|
2201
|
+
disabled: disabled,
|
|
2202
|
+
registry: registry
|
|
2203
|
+
})
|
|
2204
|
+
})
|
|
2205
|
+
});
|
|
2163
2206
|
}
|
|
2164
2207
|
|
|
2165
2208
|
function buttonTemplates() {
|
|
@@ -2182,16 +2225,18 @@
|
|
|
2182
2225
|
if (!description) {
|
|
2183
2226
|
return null;
|
|
2184
2227
|
}
|
|
2185
|
-
if (typeof description ===
|
|
2186
|
-
return
|
|
2228
|
+
if (typeof description === 'string') {
|
|
2229
|
+
return jsxRuntime.jsx("p", {
|
|
2187
2230
|
id: id,
|
|
2188
|
-
className:
|
|
2189
|
-
|
|
2231
|
+
className: 'field-description',
|
|
2232
|
+
children: description
|
|
2233
|
+
});
|
|
2190
2234
|
} else {
|
|
2191
|
-
return
|
|
2235
|
+
return jsxRuntime.jsx("div", {
|
|
2192
2236
|
id: id,
|
|
2193
|
-
className:
|
|
2194
|
-
|
|
2237
|
+
className: 'field-description',
|
|
2238
|
+
children: description
|
|
2239
|
+
});
|
|
2195
2240
|
}
|
|
2196
2241
|
}
|
|
2197
2242
|
|
|
@@ -2200,24 +2245,30 @@
|
|
|
2200
2245
|
* @param props - The `ErrorListProps` for this component
|
|
2201
2246
|
*/
|
|
2202
2247
|
function ErrorList(_ref) {
|
|
2203
|
-
var errors = _ref.errors
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
className:
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
className:
|
|
2216
|
-
|
|
2217
|
-
|
|
2248
|
+
var errors = _ref.errors,
|
|
2249
|
+
registry = _ref.registry;
|
|
2250
|
+
var translateString = registry.translateString;
|
|
2251
|
+
return jsxRuntime.jsxs("div", {
|
|
2252
|
+
className: 'panel panel-danger errors',
|
|
2253
|
+
children: [jsxRuntime.jsx("div", {
|
|
2254
|
+
className: 'panel-heading',
|
|
2255
|
+
children: jsxRuntime.jsx("h3", {
|
|
2256
|
+
className: 'panel-title',
|
|
2257
|
+
children: translateString(utils.TranslatableString.ErrorsLabel)
|
|
2258
|
+
})
|
|
2259
|
+
}), jsxRuntime.jsx("ul", {
|
|
2260
|
+
className: 'list-group',
|
|
2261
|
+
children: errors.map(function (error, i) {
|
|
2262
|
+
return jsxRuntime.jsx("li", {
|
|
2263
|
+
className: 'list-group-item text-danger',
|
|
2264
|
+
children: error.stack
|
|
2265
|
+
}, i);
|
|
2266
|
+
})
|
|
2267
|
+
})]
|
|
2268
|
+
});
|
|
2218
2269
|
}
|
|
2219
2270
|
|
|
2220
|
-
var REQUIRED_FIELD_SYMBOL$1 =
|
|
2271
|
+
var REQUIRED_FIELD_SYMBOL$1 = '*';
|
|
2221
2272
|
/** Renders a label for a field
|
|
2222
2273
|
*
|
|
2223
2274
|
* @param props - The `LabelProps` for this component
|
|
@@ -2229,12 +2280,14 @@
|
|
|
2229
2280
|
if (!label) {
|
|
2230
2281
|
return null;
|
|
2231
2282
|
}
|
|
2232
|
-
return
|
|
2233
|
-
className:
|
|
2234
|
-
htmlFor: id
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2283
|
+
return jsxRuntime.jsxs("label", {
|
|
2284
|
+
className: 'control-label',
|
|
2285
|
+
htmlFor: id,
|
|
2286
|
+
children: [label, required && jsxRuntime.jsx("span", {
|
|
2287
|
+
className: 'required',
|
|
2288
|
+
children: REQUIRED_FIELD_SYMBOL$1
|
|
2289
|
+
})]
|
|
2290
|
+
});
|
|
2238
2291
|
}
|
|
2239
2292
|
|
|
2240
2293
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -2255,17 +2308,20 @@
|
|
|
2255
2308
|
registry = props.registry,
|
|
2256
2309
|
uiSchema = props.uiSchema;
|
|
2257
2310
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
2258
|
-
var WrapIfAdditionalTemplate = utils.getTemplate(
|
|
2311
|
+
var WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
2259
2312
|
if (hidden) {
|
|
2260
|
-
return
|
|
2261
|
-
className:
|
|
2262
|
-
|
|
2313
|
+
return jsxRuntime.jsx("div", {
|
|
2314
|
+
className: 'hidden',
|
|
2315
|
+
children: children
|
|
2316
|
+
});
|
|
2263
2317
|
}
|
|
2264
|
-
return
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2318
|
+
return jsxRuntime.jsxs(WrapIfAdditionalTemplate, _extends({}, props, {
|
|
2319
|
+
children: [displayLabel && jsxRuntime.jsx(Label, {
|
|
2320
|
+
label: label,
|
|
2321
|
+
required: required,
|
|
2322
|
+
id: id
|
|
2323
|
+
}), displayLabel && description ? description : null, children, errors, help]
|
|
2324
|
+
}));
|
|
2269
2325
|
}
|
|
2270
2326
|
|
|
2271
2327
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -2280,17 +2336,20 @@
|
|
|
2280
2336
|
return null;
|
|
2281
2337
|
}
|
|
2282
2338
|
var id = utils.errorId(idSchema);
|
|
2283
|
-
return
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2339
|
+
return jsxRuntime.jsx("div", {
|
|
2340
|
+
children: jsxRuntime.jsx("ul", {
|
|
2341
|
+
id: id,
|
|
2342
|
+
className: 'error-detail bs-callout bs-callout-info',
|
|
2343
|
+
children: errors.filter(function (elem) {
|
|
2344
|
+
return !!elem;
|
|
2345
|
+
}).map(function (error, index) {
|
|
2346
|
+
return jsxRuntime.jsx("li", {
|
|
2347
|
+
className: 'text-danger',
|
|
2348
|
+
children: error
|
|
2349
|
+
}, index);
|
|
2350
|
+
})
|
|
2351
|
+
})
|
|
2352
|
+
});
|
|
2294
2353
|
}
|
|
2295
2354
|
|
|
2296
2355
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -2304,16 +2363,18 @@
|
|
|
2304
2363
|
return null;
|
|
2305
2364
|
}
|
|
2306
2365
|
var id = utils.helpId(idSchema);
|
|
2307
|
-
if (typeof help ===
|
|
2308
|
-
return
|
|
2366
|
+
if (typeof help === 'string') {
|
|
2367
|
+
return jsxRuntime.jsx("p", {
|
|
2309
2368
|
id: id,
|
|
2310
|
-
className:
|
|
2311
|
-
|
|
2369
|
+
className: 'help-block',
|
|
2370
|
+
children: help
|
|
2371
|
+
});
|
|
2312
2372
|
}
|
|
2313
|
-
return
|
|
2373
|
+
return jsxRuntime.jsx("div", {
|
|
2314
2374
|
id: id,
|
|
2315
|
-
className:
|
|
2316
|
-
|
|
2375
|
+
className: 'help-block',
|
|
2376
|
+
children: help
|
|
2377
|
+
});
|
|
2317
2378
|
}
|
|
2318
2379
|
|
|
2319
2380
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -2336,37 +2397,38 @@
|
|
|
2336
2397
|
title = props.title,
|
|
2337
2398
|
uiSchema = props.uiSchema;
|
|
2338
2399
|
var options = utils.getUiOptions(uiSchema);
|
|
2339
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
2340
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
2400
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
2401
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2341
2402
|
// Button templates are not overridden in the uiSchema
|
|
2342
2403
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2343
|
-
return
|
|
2344
|
-
id: idSchema.$id
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2404
|
+
return jsxRuntime.jsxs("fieldset", {
|
|
2405
|
+
id: idSchema.$id,
|
|
2406
|
+
children: [(options.title || title) && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2407
|
+
id: utils.titleId(idSchema),
|
|
2408
|
+
title: options.title || title,
|
|
2409
|
+
required: required,
|
|
2410
|
+
schema: schema,
|
|
2411
|
+
uiSchema: uiSchema,
|
|
2412
|
+
registry: registry
|
|
2413
|
+
}), (options.description || description) && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2414
|
+
id: utils.descriptionId(idSchema),
|
|
2415
|
+
description: options.description || description,
|
|
2416
|
+
schema: schema,
|
|
2417
|
+
uiSchema: uiSchema,
|
|
2418
|
+
registry: registry
|
|
2419
|
+
}), properties.map(function (prop) {
|
|
2420
|
+
return prop.content;
|
|
2421
|
+
}), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(AddButton, {
|
|
2422
|
+
className: 'object-property-expand',
|
|
2423
|
+
onClick: onAddClick(schema),
|
|
2424
|
+
disabled: disabled || readonly,
|
|
2425
|
+
uiSchema: uiSchema,
|
|
2426
|
+
registry: registry
|
|
2427
|
+
})]
|
|
2428
|
+
});
|
|
2367
2429
|
}
|
|
2368
2430
|
|
|
2369
|
-
var REQUIRED_FIELD_SYMBOL =
|
|
2431
|
+
var REQUIRED_FIELD_SYMBOL = '*';
|
|
2370
2432
|
/** The `TitleField` is the template to use to render the title of a field
|
|
2371
2433
|
*
|
|
2372
2434
|
* @param props - The `TitleFieldProps` for this component
|
|
@@ -2375,11 +2437,13 @@
|
|
|
2375
2437
|
var id = props.id,
|
|
2376
2438
|
title = props.title,
|
|
2377
2439
|
required = props.required;
|
|
2378
|
-
return
|
|
2379
|
-
id: id
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2440
|
+
return jsxRuntime.jsxs("legend", {
|
|
2441
|
+
id: id,
|
|
2442
|
+
children: [title, required && jsxRuntime.jsx("span", {
|
|
2443
|
+
className: 'required',
|
|
2444
|
+
children: REQUIRED_FIELD_SYMBOL
|
|
2445
|
+
})]
|
|
2446
|
+
});
|
|
2383
2447
|
}
|
|
2384
2448
|
|
|
2385
2449
|
/** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
|
|
@@ -2390,10 +2454,29 @@
|
|
|
2390
2454
|
function UnsupportedField(props) {
|
|
2391
2455
|
var schema = props.schema,
|
|
2392
2456
|
idSchema = props.idSchema,
|
|
2393
|
-
reason = props.reason
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2457
|
+
reason = props.reason,
|
|
2458
|
+
registry = props.registry;
|
|
2459
|
+
var translateString = registry.translateString;
|
|
2460
|
+
var translateEnum = utils.TranslatableString.UnsupportedField;
|
|
2461
|
+
var translateParams = [];
|
|
2462
|
+
if (idSchema && idSchema.$id) {
|
|
2463
|
+
translateEnum = utils.TranslatableString.UnsupportedFieldWithId;
|
|
2464
|
+
translateParams.push(idSchema.$id);
|
|
2465
|
+
}
|
|
2466
|
+
if (reason) {
|
|
2467
|
+
translateEnum = translateEnum === utils.TranslatableString.UnsupportedField ? utils.TranslatableString.UnsupportedFieldWithReason : utils.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2468
|
+
translateParams.push(reason);
|
|
2469
|
+
}
|
|
2470
|
+
return jsxRuntime.jsxs("div", {
|
|
2471
|
+
className: 'unsupported-field',
|
|
2472
|
+
children: [jsxRuntime.jsx("p", {
|
|
2473
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
2474
|
+
children: translateString(translateEnum, translateParams)
|
|
2475
|
+
})
|
|
2476
|
+
}), schema && jsxRuntime.jsx("pre", {
|
|
2477
|
+
children: JSON.stringify(schema, null, 2)
|
|
2478
|
+
})]
|
|
2479
|
+
});
|
|
2397
2480
|
}
|
|
2398
2481
|
|
|
2399
2482
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -2415,51 +2498,60 @@
|
|
|
2415
2498
|
children = props.children,
|
|
2416
2499
|
uiSchema = props.uiSchema,
|
|
2417
2500
|
registry = props.registry;
|
|
2501
|
+
var templates = registry.templates,
|
|
2502
|
+
translateString = registry.translateString;
|
|
2418
2503
|
// Button templates are not overridden in the uiSchema
|
|
2419
|
-
var RemoveButton =
|
|
2420
|
-
var keyLabel = label
|
|
2504
|
+
var RemoveButton = templates.ButtonTemplates.RemoveButton;
|
|
2505
|
+
var keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
2421
2506
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2422
2507
|
if (!additional) {
|
|
2423
|
-
return
|
|
2508
|
+
return jsxRuntime.jsx("div", {
|
|
2424
2509
|
className: classNames,
|
|
2425
|
-
style: style
|
|
2426
|
-
|
|
2510
|
+
style: style,
|
|
2511
|
+
children: children
|
|
2512
|
+
});
|
|
2427
2513
|
}
|
|
2428
|
-
return
|
|
2514
|
+
return jsxRuntime.jsx("div", {
|
|
2429
2515
|
className: classNames,
|
|
2430
|
-
style: style
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2516
|
+
style: style,
|
|
2517
|
+
children: jsxRuntime.jsxs("div", {
|
|
2518
|
+
className: 'row',
|
|
2519
|
+
children: [jsxRuntime.jsx("div", {
|
|
2520
|
+
className: 'col-xs-5 form-additional',
|
|
2521
|
+
children: jsxRuntime.jsxs("div", {
|
|
2522
|
+
className: 'form-group',
|
|
2523
|
+
children: [jsxRuntime.jsx(Label, {
|
|
2524
|
+
label: keyLabel,
|
|
2525
|
+
required: required,
|
|
2526
|
+
id: id + "-key"
|
|
2527
|
+
}), jsxRuntime.jsx("input", {
|
|
2528
|
+
className: 'form-control',
|
|
2529
|
+
type: 'text',
|
|
2530
|
+
id: id + "-key",
|
|
2531
|
+
onBlur: function onBlur(event) {
|
|
2532
|
+
return onKeyChange(event.target.value);
|
|
2533
|
+
},
|
|
2534
|
+
defaultValue: label
|
|
2535
|
+
})]
|
|
2536
|
+
})
|
|
2537
|
+
}), jsxRuntime.jsx("div", {
|
|
2538
|
+
className: 'form-additional form-group col-xs-5',
|
|
2539
|
+
children: children
|
|
2540
|
+
}), jsxRuntime.jsx("div", {
|
|
2541
|
+
className: 'col-xs-2',
|
|
2542
|
+
children: jsxRuntime.jsx(RemoveButton, {
|
|
2543
|
+
className: 'array-item-remove btn-block',
|
|
2544
|
+
style: {
|
|
2545
|
+
border: '0'
|
|
2546
|
+
},
|
|
2547
|
+
disabled: disabled || readonly,
|
|
2548
|
+
onClick: onDropPropertyClick(label),
|
|
2549
|
+
uiSchema: uiSchema,
|
|
2550
|
+
registry: registry
|
|
2551
|
+
})
|
|
2552
|
+
})]
|
|
2553
|
+
})
|
|
2554
|
+
});
|
|
2463
2555
|
}
|
|
2464
2556
|
|
|
2465
2557
|
function templates() {
|
|
@@ -2508,29 +2600,29 @@
|
|
|
2508
2600
|
minute = state.minute,
|
|
2509
2601
|
second = state.second;
|
|
2510
2602
|
var data = [{
|
|
2511
|
-
type:
|
|
2603
|
+
type: 'year',
|
|
2512
2604
|
range: yearsRange,
|
|
2513
2605
|
value: year
|
|
2514
2606
|
}, {
|
|
2515
|
-
type:
|
|
2607
|
+
type: 'month',
|
|
2516
2608
|
range: [1, 12],
|
|
2517
2609
|
value: month
|
|
2518
2610
|
}, {
|
|
2519
|
-
type:
|
|
2611
|
+
type: 'day',
|
|
2520
2612
|
range: [1, 31],
|
|
2521
2613
|
value: day
|
|
2522
2614
|
}];
|
|
2523
2615
|
if (time) {
|
|
2524
2616
|
data.push({
|
|
2525
|
-
type:
|
|
2617
|
+
type: 'hour',
|
|
2526
2618
|
range: [0, 23],
|
|
2527
2619
|
value: hour
|
|
2528
2620
|
}, {
|
|
2529
|
-
type:
|
|
2621
|
+
type: 'minute',
|
|
2530
2622
|
range: [0, 59],
|
|
2531
2623
|
value: minute
|
|
2532
2624
|
}, {
|
|
2533
|
-
type:
|
|
2625
|
+
type: 'second',
|
|
2534
2626
|
range: [0, 59],
|
|
2535
2627
|
value: second
|
|
2536
2628
|
});
|
|
@@ -2543,20 +2635,22 @@
|
|
|
2543
2635
|
value = _ref.value,
|
|
2544
2636
|
select = _ref.select,
|
|
2545
2637
|
rootId = _ref.rootId,
|
|
2638
|
+
name = _ref.name,
|
|
2546
2639
|
disabled = _ref.disabled,
|
|
2547
2640
|
readonly = _ref.readonly,
|
|
2548
2641
|
autofocus = _ref.autofocus,
|
|
2549
2642
|
registry = _ref.registry,
|
|
2550
2643
|
onBlur = _ref.onBlur,
|
|
2551
2644
|
onFocus = _ref.onFocus;
|
|
2552
|
-
var id = rootId +
|
|
2645
|
+
var id = rootId + '_' + type;
|
|
2553
2646
|
var SelectWidget = registry.widgets.SelectWidget;
|
|
2554
|
-
return
|
|
2647
|
+
return jsxRuntime.jsx(SelectWidget, {
|
|
2555
2648
|
schema: {
|
|
2556
|
-
type:
|
|
2649
|
+
type: 'integer'
|
|
2557
2650
|
},
|
|
2558
2651
|
id: id,
|
|
2559
|
-
|
|
2652
|
+
name: name,
|
|
2653
|
+
className: 'form-control',
|
|
2560
2654
|
options: {
|
|
2561
2655
|
enumOptions: rangeOptions(range[0], range[1])
|
|
2562
2656
|
},
|
|
@@ -2571,7 +2665,7 @@
|
|
|
2571
2665
|
onBlur: onBlur,
|
|
2572
2666
|
onFocus: onFocus,
|
|
2573
2667
|
registry: registry,
|
|
2574
|
-
label:
|
|
2668
|
+
label: '',
|
|
2575
2669
|
"aria-describedby": utils.ariaDescribedByIds(rootId)
|
|
2576
2670
|
});
|
|
2577
2671
|
}
|
|
@@ -2589,32 +2683,34 @@
|
|
|
2589
2683
|
autofocus = _ref2$autofocus === void 0 ? false : _ref2$autofocus,
|
|
2590
2684
|
options = _ref2.options,
|
|
2591
2685
|
id = _ref2.id,
|
|
2686
|
+
name = _ref2.name,
|
|
2592
2687
|
registry = _ref2.registry,
|
|
2593
2688
|
onBlur = _ref2.onBlur,
|
|
2594
2689
|
onFocus = _ref2.onFocus,
|
|
2595
2690
|
onChange = _ref2.onChange,
|
|
2596
2691
|
value = _ref2.value;
|
|
2597
|
-
var
|
|
2692
|
+
var translateString = registry.translateString;
|
|
2693
|
+
var _useReducer = react.useReducer(function (state, action) {
|
|
2598
2694
|
return _extends({}, state, action);
|
|
2599
2695
|
}, utils.parseDateString(value, time)),
|
|
2600
2696
|
state = _useReducer[0],
|
|
2601
2697
|
setState = _useReducer[1];
|
|
2602
|
-
|
|
2698
|
+
react.useEffect(function () {
|
|
2603
2699
|
if (value && value !== utils.toDateString(state, time)) {
|
|
2604
2700
|
setState(utils.parseDateString(value, time));
|
|
2605
2701
|
}
|
|
2606
2702
|
}, [value, state, time]);
|
|
2607
|
-
|
|
2703
|
+
react.useEffect(function () {
|
|
2608
2704
|
if (readyForChange(state)) {
|
|
2609
2705
|
// Only propagate to parent state if we have a complete date{time}
|
|
2610
2706
|
onChange(utils.toDateString(state, time));
|
|
2611
2707
|
}
|
|
2612
2708
|
}, [state, time, onChange]);
|
|
2613
|
-
var handleChange =
|
|
2709
|
+
var handleChange = react.useCallback(function (property, value) {
|
|
2614
2710
|
var _setState;
|
|
2615
2711
|
setState((_setState = {}, _setState[property] = value, _setState));
|
|
2616
2712
|
}, []);
|
|
2617
|
-
var handleSetNow =
|
|
2713
|
+
var handleSetNow = react.useCallback(function (event) {
|
|
2618
2714
|
event.preventDefault();
|
|
2619
2715
|
if (disabled || readonly) {
|
|
2620
2716
|
return;
|
|
@@ -2622,44 +2718,50 @@
|
|
|
2622
2718
|
var nowDateObj = utils.parseDateString(new Date().toJSON(), time);
|
|
2623
2719
|
setState(nowDateObj);
|
|
2624
2720
|
}, [disabled, readonly, time]);
|
|
2625
|
-
var handleClear =
|
|
2721
|
+
var handleClear = react.useCallback(function (event) {
|
|
2626
2722
|
event.preventDefault();
|
|
2627
2723
|
if (disabled || readonly) {
|
|
2628
2724
|
return;
|
|
2629
2725
|
}
|
|
2630
|
-
setState(utils.parseDateString(
|
|
2726
|
+
setState(utils.parseDateString('', time));
|
|
2631
2727
|
onChange(undefined);
|
|
2632
2728
|
}, [disabled, readonly, time, onChange]);
|
|
2633
|
-
return
|
|
2634
|
-
className:
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2729
|
+
return jsxRuntime.jsxs("ul", {
|
|
2730
|
+
className: 'list-inline',
|
|
2731
|
+
children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2732
|
+
return jsxRuntime.jsx("li", {
|
|
2733
|
+
className: 'list-inline-item',
|
|
2734
|
+
children: jsxRuntime.jsx(DateElement, _extends({
|
|
2735
|
+
rootId: id,
|
|
2736
|
+
name: name,
|
|
2737
|
+
select: handleChange
|
|
2738
|
+
}, elemProps, {
|
|
2739
|
+
disabled: disabled,
|
|
2740
|
+
readonly: readonly,
|
|
2741
|
+
registry: registry,
|
|
2742
|
+
onBlur: onBlur,
|
|
2743
|
+
onFocus: onFocus,
|
|
2744
|
+
autofocus: autofocus && i === 0
|
|
2745
|
+
}))
|
|
2746
|
+
}, i);
|
|
2747
|
+
}), (options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && jsxRuntime.jsx("li", {
|
|
2748
|
+
className: 'list-inline-item',
|
|
2749
|
+
children: jsxRuntime.jsx("a", {
|
|
2750
|
+
href: '#',
|
|
2751
|
+
className: 'btn btn-info btn-now',
|
|
2752
|
+
onClick: handleSetNow,
|
|
2753
|
+
children: translateString(utils.TranslatableString.NowLabel)
|
|
2754
|
+
})
|
|
2755
|
+
}), (options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && jsxRuntime.jsx("li", {
|
|
2756
|
+
className: 'list-inline-item',
|
|
2757
|
+
children: jsxRuntime.jsx("a", {
|
|
2758
|
+
href: '#',
|
|
2759
|
+
className: 'btn btn-warning btn-clear',
|
|
2760
|
+
onClick: handleClear,
|
|
2761
|
+
children: translateString(utils.TranslatableString.ClearLabel)
|
|
2762
|
+
})
|
|
2763
|
+
})]
|
|
2764
|
+
});
|
|
2663
2765
|
}
|
|
2664
2766
|
|
|
2665
2767
|
var _excluded$1 = ["time"];
|
|
@@ -2673,7 +2775,7 @@
|
|
|
2673
2775
|
time = _ref$time === void 0 ? true : _ref$time,
|
|
2674
2776
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2675
2777
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
2676
|
-
return
|
|
2778
|
+
return jsxRuntime.jsx(AltDateWidget, _extends({
|
|
2677
2779
|
time: time
|
|
2678
2780
|
}, props));
|
|
2679
2781
|
}
|
|
@@ -2698,41 +2800,46 @@
|
|
|
2698
2800
|
onFocus = _ref.onFocus,
|
|
2699
2801
|
onChange = _ref.onChange,
|
|
2700
2802
|
registry = _ref.registry;
|
|
2701
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
2803
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2702
2804
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
2703
2805
|
// the "required" attribute if the field value must be "true", due to the
|
|
2704
2806
|
// "const" or "enum" keywords
|
|
2705
2807
|
var required = utils.schemaRequiresTrueValue(schema);
|
|
2706
|
-
var handleChange =
|
|
2808
|
+
var handleChange = react.useCallback(function (event) {
|
|
2707
2809
|
return onChange(event.target.checked);
|
|
2708
2810
|
}, [onChange]);
|
|
2709
|
-
var handleBlur =
|
|
2811
|
+
var handleBlur = react.useCallback(function (event) {
|
|
2710
2812
|
return onBlur(id, event.target.checked);
|
|
2711
2813
|
}, [onBlur, id]);
|
|
2712
|
-
var handleFocus =
|
|
2814
|
+
var handleFocus = react.useCallback(function (event) {
|
|
2713
2815
|
return onFocus(id, event.target.checked);
|
|
2714
2816
|
}, [onFocus, id]);
|
|
2715
|
-
return
|
|
2716
|
-
className: "checkbox " + (disabled || readonly ?
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2817
|
+
return jsxRuntime.jsxs("div", {
|
|
2818
|
+
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2819
|
+
children: [schema.description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2820
|
+
id: utils.descriptionId(id),
|
|
2821
|
+
description: schema.description,
|
|
2822
|
+
schema: schema,
|
|
2823
|
+
uiSchema: uiSchema,
|
|
2824
|
+
registry: registry
|
|
2825
|
+
}), jsxRuntime.jsxs("label", {
|
|
2826
|
+
children: [jsxRuntime.jsx("input", {
|
|
2827
|
+
type: 'checkbox',
|
|
2828
|
+
id: id,
|
|
2829
|
+
name: id,
|
|
2830
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
2831
|
+
required: required,
|
|
2832
|
+
disabled: disabled || readonly,
|
|
2833
|
+
autoFocus: autofocus,
|
|
2834
|
+
onChange: handleChange,
|
|
2835
|
+
onBlur: handleBlur,
|
|
2836
|
+
onFocus: handleFocus,
|
|
2837
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2838
|
+
}), jsxRuntime.jsx("span", {
|
|
2839
|
+
children: label
|
|
2840
|
+
})]
|
|
2841
|
+
})]
|
|
2842
|
+
});
|
|
2736
2843
|
}
|
|
2737
2844
|
|
|
2738
2845
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
@@ -2757,49 +2864,56 @@
|
|
|
2757
2864
|
onBlur = _ref.onBlur,
|
|
2758
2865
|
onFocus = _ref.onFocus;
|
|
2759
2866
|
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2760
|
-
var handleBlur =
|
|
2867
|
+
var handleBlur = react.useCallback(function (_ref2) {
|
|
2761
2868
|
var value = _ref2.target.value;
|
|
2762
2869
|
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2763
2870
|
}, [onBlur, id]);
|
|
2764
|
-
var handleFocus =
|
|
2871
|
+
var handleFocus = react.useCallback(function (_ref3) {
|
|
2765
2872
|
var value = _ref3.target.value;
|
|
2766
2873
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2767
2874
|
}, [onFocus, id]);
|
|
2768
|
-
return
|
|
2769
|
-
className:
|
|
2770
|
-
id: id
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2875
|
+
return jsxRuntime.jsx("div", {
|
|
2876
|
+
className: 'checkboxes',
|
|
2877
|
+
id: id,
|
|
2878
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2879
|
+
var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
2880
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2881
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
2882
|
+
var handleChange = function handleChange(event) {
|
|
2883
|
+
if (event.target.checked) {
|
|
2884
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
2885
|
+
} else {
|
|
2886
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
var checkbox = jsxRuntime.jsxs("span", {
|
|
2890
|
+
children: [jsxRuntime.jsx("input", {
|
|
2891
|
+
type: 'checkbox',
|
|
2892
|
+
id: utils.optionId(id, index),
|
|
2893
|
+
name: id,
|
|
2894
|
+
checked: checked,
|
|
2895
|
+
value: String(index),
|
|
2896
|
+
disabled: disabled || itemDisabled || readonly,
|
|
2897
|
+
autoFocus: autofocus && index === 0,
|
|
2898
|
+
onChange: handleChange,
|
|
2899
|
+
onBlur: handleBlur,
|
|
2900
|
+
onFocus: handleFocus,
|
|
2901
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2902
|
+
}), jsxRuntime.jsx("span", {
|
|
2903
|
+
children: option.label
|
|
2904
|
+
})]
|
|
2905
|
+
});
|
|
2906
|
+
return inline ? jsxRuntime.jsx("label", {
|
|
2907
|
+
className: "checkbox-inline " + disabledCls,
|
|
2908
|
+
children: checkbox
|
|
2909
|
+
}, index) : jsxRuntime.jsx("div", {
|
|
2910
|
+
className: "checkbox " + disabledCls,
|
|
2911
|
+
children: jsxRuntime.jsx("label", {
|
|
2912
|
+
children: checkbox
|
|
2913
|
+
})
|
|
2914
|
+
}, index);
|
|
2915
|
+
})
|
|
2916
|
+
});
|
|
2803
2917
|
}
|
|
2804
2918
|
|
|
2805
2919
|
/** The `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
|
|
@@ -2812,9 +2926,9 @@
|
|
|
2812
2926
|
readonly = props.readonly,
|
|
2813
2927
|
options = props.options,
|
|
2814
2928
|
registry = props.registry;
|
|
2815
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2816
|
-
return
|
|
2817
|
-
type:
|
|
2929
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2930
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2931
|
+
type: 'color'
|
|
2818
2932
|
}, props, {
|
|
2819
2933
|
disabled: disabled || readonly
|
|
2820
2934
|
}));
|
|
@@ -2829,12 +2943,12 @@
|
|
|
2829
2943
|
var onChange = props.onChange,
|
|
2830
2944
|
options = props.options,
|
|
2831
2945
|
registry = props.registry;
|
|
2832
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2833
|
-
var handleChange =
|
|
2946
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2947
|
+
var handleChange = react.useCallback(function (value) {
|
|
2834
2948
|
return onChange(value || undefined);
|
|
2835
2949
|
}, [onChange]);
|
|
2836
|
-
return
|
|
2837
|
-
type:
|
|
2950
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2951
|
+
type: 'date'
|
|
2838
2952
|
}, props, {
|
|
2839
2953
|
onChange: handleChange
|
|
2840
2954
|
}));
|
|
@@ -2850,9 +2964,9 @@
|
|
|
2850
2964
|
value = props.value,
|
|
2851
2965
|
options = props.options,
|
|
2852
2966
|
registry = props.registry;
|
|
2853
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2854
|
-
return
|
|
2855
|
-
type:
|
|
2967
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2968
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2969
|
+
type: 'datetime-local'
|
|
2856
2970
|
}, props, {
|
|
2857
2971
|
value: utils.utcToLocal(value),
|
|
2858
2972
|
onChange: function onChange(value) {
|
|
@@ -2868,9 +2982,9 @@
|
|
|
2868
2982
|
function EmailWidget(props) {
|
|
2869
2983
|
var options = props.options,
|
|
2870
2984
|
registry = props.registry;
|
|
2871
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2872
|
-
return
|
|
2873
|
-
type:
|
|
2985
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2986
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2987
|
+
type: 'email'
|
|
2874
2988
|
}, props));
|
|
2875
2989
|
}
|
|
2876
2990
|
|
|
@@ -2878,7 +2992,7 @@
|
|
|
2878
2992
|
if (dataURL === null) {
|
|
2879
2993
|
return null;
|
|
2880
2994
|
}
|
|
2881
|
-
return dataURL.replace(
|
|
2995
|
+
return dataURL.replace(';base64', ";name=" + encodeURIComponent(name) + ";base64");
|
|
2882
2996
|
}
|
|
2883
2997
|
function processFile(file) {
|
|
2884
2998
|
var name = file.name,
|
|
@@ -2889,7 +3003,7 @@
|
|
|
2889
3003
|
reader.onerror = reject;
|
|
2890
3004
|
reader.onload = function (event) {
|
|
2891
3005
|
var _event$target;
|
|
2892
|
-
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) ===
|
|
3006
|
+
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) === 'string') {
|
|
2893
3007
|
resolve({
|
|
2894
3008
|
dataURL: addNameToDataURL(event.target.result, name),
|
|
2895
3009
|
name: name,
|
|
@@ -2912,24 +3026,29 @@
|
|
|
2912
3026
|
return Promise.all(Array.from(files).map(processFile));
|
|
2913
3027
|
}
|
|
2914
3028
|
function FilesInfo(_ref) {
|
|
2915
|
-
var filesInfo = _ref.filesInfo
|
|
3029
|
+
var filesInfo = _ref.filesInfo,
|
|
3030
|
+
registry = _ref.registry;
|
|
2916
3031
|
if (filesInfo.length === 0) {
|
|
2917
3032
|
return null;
|
|
2918
3033
|
}
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
3034
|
+
var translateString = registry.translateString;
|
|
3035
|
+
return jsxRuntime.jsx("ul", {
|
|
3036
|
+
className: 'file-info',
|
|
3037
|
+
children: filesInfo.map(function (fileInfo, key) {
|
|
3038
|
+
var name = fileInfo.name,
|
|
3039
|
+
size = fileInfo.size,
|
|
3040
|
+
type = fileInfo.type;
|
|
3041
|
+
return jsxRuntime.jsx("li", {
|
|
3042
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3043
|
+
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3044
|
+
})
|
|
3045
|
+
}, key);
|
|
3046
|
+
})
|
|
3047
|
+
});
|
|
2929
3048
|
}
|
|
2930
3049
|
function extractFileInfo(dataURLs) {
|
|
2931
3050
|
return dataURLs.filter(function (dataURL) {
|
|
2932
|
-
return
|
|
3051
|
+
return dataURL;
|
|
2933
3052
|
}).map(function (dataURL) {
|
|
2934
3053
|
var _dataURItoBlob = utils.dataURItoBlob(dataURL),
|
|
2935
3054
|
blob = _dataURItoBlob.blob,
|
|
@@ -2945,23 +3064,22 @@
|
|
|
2945
3064
|
* The `FileWidget` is a widget for rendering file upload fields.
|
|
2946
3065
|
* It is typically used with a string property with data-url format.
|
|
2947
3066
|
*/
|
|
2948
|
-
function FileWidget(
|
|
2949
|
-
var
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
var extractedFilesInfo = React.useMemo(function () {
|
|
3067
|
+
function FileWidget(props) {
|
|
3068
|
+
var disabled = props.disabled,
|
|
3069
|
+
readonly = props.readonly,
|
|
3070
|
+
multiple = props.multiple,
|
|
3071
|
+
onChange = props.onChange,
|
|
3072
|
+
value = props.value,
|
|
3073
|
+
options = props.options,
|
|
3074
|
+
registry = props.registry;
|
|
3075
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3076
|
+
var extractedFilesInfo = react.useMemo(function () {
|
|
2959
3077
|
return Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value]);
|
|
2960
3078
|
}, [value]);
|
|
2961
|
-
var _useState =
|
|
3079
|
+
var _useState = react.useState(extractedFilesInfo),
|
|
2962
3080
|
filesInfo = _useState[0],
|
|
2963
3081
|
setFilesInfo = _useState[1];
|
|
2964
|
-
var handleChange =
|
|
3082
|
+
var handleChange = react.useCallback(function (event) {
|
|
2965
3083
|
if (!event.target.files) {
|
|
2966
3084
|
return;
|
|
2967
3085
|
}
|
|
@@ -2977,20 +3095,18 @@
|
|
|
2977
3095
|
}
|
|
2978
3096
|
});
|
|
2979
3097
|
}, [multiple, onChange]);
|
|
2980
|
-
return
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
})
|
|
2992
|
-
filesInfo: filesInfo
|
|
2993
|
-
}));
|
|
3098
|
+
return jsxRuntime.jsxs("div", {
|
|
3099
|
+
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({}, props, {
|
|
3100
|
+
disabled: disabled || readonly,
|
|
3101
|
+
type: 'file',
|
|
3102
|
+
onChangeOverride: handleChange,
|
|
3103
|
+
value: '',
|
|
3104
|
+
accept: options.accept ? String(options.accept) : undefined
|
|
3105
|
+
})), jsxRuntime.jsx(FilesInfo, {
|
|
3106
|
+
filesInfo: filesInfo,
|
|
3107
|
+
registry: registry
|
|
3108
|
+
})]
|
|
3109
|
+
});
|
|
2994
3110
|
}
|
|
2995
3111
|
|
|
2996
3112
|
/** The `HiddenWidget` is a widget for rendering a hidden input field.
|
|
@@ -3001,11 +3117,11 @@
|
|
|
3001
3117
|
function HiddenWidget(_ref) {
|
|
3002
3118
|
var id = _ref.id,
|
|
3003
3119
|
value = _ref.value;
|
|
3004
|
-
return
|
|
3005
|
-
type:
|
|
3120
|
+
return jsxRuntime.jsx("input", {
|
|
3121
|
+
type: 'hidden',
|
|
3006
3122
|
id: id,
|
|
3007
3123
|
name: id,
|
|
3008
|
-
value: typeof value ===
|
|
3124
|
+
value: typeof value === 'undefined' ? '' : value
|
|
3009
3125
|
});
|
|
3010
3126
|
}
|
|
3011
3127
|
|
|
@@ -3016,9 +3132,9 @@
|
|
|
3016
3132
|
function PasswordWidget(props) {
|
|
3017
3133
|
var options = props.options,
|
|
3018
3134
|
registry = props.registry;
|
|
3019
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3020
|
-
return
|
|
3021
|
-
type:
|
|
3135
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3136
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3137
|
+
type: 'password'
|
|
3022
3138
|
}, props));
|
|
3023
3139
|
}
|
|
3024
3140
|
|
|
@@ -3045,46 +3161,53 @@
|
|
|
3045
3161
|
enumDisabled = options.enumDisabled,
|
|
3046
3162
|
inline = options.inline,
|
|
3047
3163
|
emptyValue = options.emptyValue;
|
|
3048
|
-
var handleBlur =
|
|
3164
|
+
var handleBlur = react.useCallback(function (_ref2) {
|
|
3049
3165
|
var value = _ref2.target.value;
|
|
3050
3166
|
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3051
3167
|
}, [onBlur, id]);
|
|
3052
|
-
var handleFocus =
|
|
3168
|
+
var handleFocus = react.useCallback(function (_ref3) {
|
|
3053
3169
|
var value = _ref3.target.value;
|
|
3054
3170
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3055
3171
|
}, [onFocus, id]);
|
|
3056
|
-
return
|
|
3057
|
-
className:
|
|
3058
|
-
id: id
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3172
|
+
return jsxRuntime.jsx("div", {
|
|
3173
|
+
className: 'field-radio-group',
|
|
3174
|
+
id: id,
|
|
3175
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
3176
|
+
var checked = utils.enumOptionsIsSelected(option.value, value);
|
|
3177
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3178
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
3179
|
+
var handleChange = function handleChange() {
|
|
3180
|
+
return onChange(option.value);
|
|
3181
|
+
};
|
|
3182
|
+
var radio = jsxRuntime.jsxs("span", {
|
|
3183
|
+
children: [jsxRuntime.jsx("input", {
|
|
3184
|
+
type: 'radio',
|
|
3185
|
+
id: utils.optionId(id, i),
|
|
3186
|
+
checked: checked,
|
|
3187
|
+
name: name,
|
|
3188
|
+
required: required,
|
|
3189
|
+
value: String(i),
|
|
3190
|
+
disabled: disabled || itemDisabled || readonly,
|
|
3191
|
+
autoFocus: autofocus && i === 0,
|
|
3192
|
+
onChange: handleChange,
|
|
3193
|
+
onBlur: handleBlur,
|
|
3194
|
+
onFocus: handleFocus,
|
|
3195
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3196
|
+
}), jsxRuntime.jsx("span", {
|
|
3197
|
+
children: option.label
|
|
3198
|
+
})]
|
|
3199
|
+
});
|
|
3200
|
+
return inline ? jsxRuntime.jsx("label", {
|
|
3201
|
+
className: "radio-inline " + disabledCls,
|
|
3202
|
+
children: radio
|
|
3203
|
+
}, i) : jsxRuntime.jsx("div", {
|
|
3204
|
+
className: "radio " + disabledCls,
|
|
3205
|
+
children: jsxRuntime.jsx("label", {
|
|
3206
|
+
children: radio
|
|
3207
|
+
})
|
|
3208
|
+
}, i);
|
|
3209
|
+
})
|
|
3210
|
+
});
|
|
3088
3211
|
}
|
|
3089
3212
|
|
|
3090
3213
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -3095,13 +3218,15 @@
|
|
|
3095
3218
|
function RangeWidget(props) {
|
|
3096
3219
|
var value = props.value,
|
|
3097
3220
|
BaseInputTemplate = props.registry.templates.BaseInputTemplate;
|
|
3098
|
-
return
|
|
3099
|
-
className:
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3221
|
+
return jsxRuntime.jsxs("div", {
|
|
3222
|
+
className: 'field-range-wrapper',
|
|
3223
|
+
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3224
|
+
type: 'range'
|
|
3225
|
+
}, props)), jsxRuntime.jsx("span", {
|
|
3226
|
+
className: 'range-view',
|
|
3227
|
+
children: value
|
|
3228
|
+
})]
|
|
3229
|
+
});
|
|
3105
3230
|
}
|
|
3106
3231
|
|
|
3107
3232
|
function getValue(event, multiple) {
|
|
@@ -3138,45 +3263,47 @@
|
|
|
3138
3263
|
var enumOptions = options.enumOptions,
|
|
3139
3264
|
enumDisabled = options.enumDisabled,
|
|
3140
3265
|
optEmptyVal = options.emptyValue;
|
|
3141
|
-
var emptyValue = multiple ? [] :
|
|
3142
|
-
var handleFocus =
|
|
3266
|
+
var emptyValue = multiple ? [] : '';
|
|
3267
|
+
var handleFocus = react.useCallback(function (event) {
|
|
3143
3268
|
var newValue = getValue(event, multiple);
|
|
3144
3269
|
return onFocus(id, utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3145
3270
|
}, [onFocus, id, schema, multiple, options]);
|
|
3146
|
-
var handleBlur =
|
|
3271
|
+
var handleBlur = react.useCallback(function (event) {
|
|
3147
3272
|
var newValue = getValue(event, multiple);
|
|
3148
3273
|
return onBlur(id, utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3149
3274
|
}, [onBlur, id, schema, multiple, options]);
|
|
3150
|
-
var handleChange =
|
|
3275
|
+
var handleChange = react.useCallback(function (event) {
|
|
3151
3276
|
var newValue = getValue(event, multiple);
|
|
3152
3277
|
return onChange(utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3153
3278
|
}, [onChange, schema, multiple, options]);
|
|
3154
3279
|
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
3155
|
-
return
|
|
3280
|
+
return jsxRuntime.jsxs("select", {
|
|
3156
3281
|
id: id,
|
|
3157
3282
|
name: id,
|
|
3158
3283
|
multiple: multiple,
|
|
3159
|
-
className:
|
|
3160
|
-
value: typeof selectedIndexes ===
|
|
3284
|
+
className: 'form-control',
|
|
3285
|
+
value: typeof selectedIndexes === 'undefined' ? emptyValue : selectedIndexes,
|
|
3161
3286
|
required: required,
|
|
3162
3287
|
disabled: disabled || readonly,
|
|
3163
3288
|
autoFocus: autofocus,
|
|
3164
3289
|
onBlur: handleBlur,
|
|
3165
3290
|
onFocus: handleFocus,
|
|
3166
3291
|
onChange: handleChange,
|
|
3167
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3292
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
3293
|
+
children: [!multiple && schema["default"] === undefined && jsxRuntime.jsx("option", {
|
|
3294
|
+
value: '',
|
|
3295
|
+
children: placeholder
|
|
3296
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
3297
|
+
var value = _ref2.value,
|
|
3298
|
+
label = _ref2.label;
|
|
3299
|
+
var disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
|
|
3300
|
+
return jsxRuntime.jsx("option", {
|
|
3301
|
+
value: String(i),
|
|
3302
|
+
disabled: disabled,
|
|
3303
|
+
children: label
|
|
3304
|
+
}, i);
|
|
3305
|
+
})]
|
|
3306
|
+
});
|
|
3180
3307
|
}
|
|
3181
3308
|
|
|
3182
3309
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -3197,23 +3324,23 @@
|
|
|
3197
3324
|
onChange = _ref.onChange,
|
|
3198
3325
|
onBlur = _ref.onBlur,
|
|
3199
3326
|
onFocus = _ref.onFocus;
|
|
3200
|
-
var handleChange =
|
|
3327
|
+
var handleChange = react.useCallback(function (_ref2) {
|
|
3201
3328
|
var value = _ref2.target.value;
|
|
3202
|
-
return onChange(value ===
|
|
3329
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
3203
3330
|
}, [onChange, options.emptyValue]);
|
|
3204
|
-
var handleBlur =
|
|
3331
|
+
var handleBlur = react.useCallback(function (_ref3) {
|
|
3205
3332
|
var value = _ref3.target.value;
|
|
3206
3333
|
return onBlur(id, value);
|
|
3207
3334
|
}, [onBlur, id]);
|
|
3208
|
-
var handleFocus =
|
|
3335
|
+
var handleFocus = react.useCallback(function (_ref4) {
|
|
3209
3336
|
var value = _ref4.target.value;
|
|
3210
3337
|
return onFocus(id, value);
|
|
3211
3338
|
}, [id, onFocus]);
|
|
3212
|
-
return
|
|
3339
|
+
return jsxRuntime.jsx("textarea", {
|
|
3213
3340
|
id: id,
|
|
3214
3341
|
name: id,
|
|
3215
|
-
className:
|
|
3216
|
-
value: value ? value :
|
|
3342
|
+
className: 'form-control',
|
|
3343
|
+
value: value ? value : '',
|
|
3217
3344
|
placeholder: placeholder,
|
|
3218
3345
|
required: required,
|
|
3219
3346
|
disabled: disabled,
|
|
@@ -3238,8 +3365,8 @@
|
|
|
3238
3365
|
function TextWidget(props) {
|
|
3239
3366
|
var options = props.options,
|
|
3240
3367
|
registry = props.registry;
|
|
3241
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3242
|
-
return
|
|
3368
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3369
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({}, props));
|
|
3243
3370
|
}
|
|
3244
3371
|
|
|
3245
3372
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
@@ -3249,9 +3376,9 @@
|
|
|
3249
3376
|
function URLWidget(props) {
|
|
3250
3377
|
var options = props.options,
|
|
3251
3378
|
registry = props.registry;
|
|
3252
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3253
|
-
return
|
|
3254
|
-
type:
|
|
3379
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3380
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3381
|
+
type: 'url'
|
|
3255
3382
|
}, props));
|
|
3256
3383
|
}
|
|
3257
3384
|
|
|
@@ -3262,9 +3389,9 @@
|
|
|
3262
3389
|
function UpDownWidget(props) {
|
|
3263
3390
|
var options = props.options,
|
|
3264
3391
|
registry = props.registry;
|
|
3265
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3266
|
-
return
|
|
3267
|
-
type:
|
|
3392
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3393
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3394
|
+
type: 'number'
|
|
3268
3395
|
}, props));
|
|
3269
3396
|
}
|
|
3270
3397
|
|
|
@@ -3301,7 +3428,8 @@
|
|
|
3301
3428
|
templates: templates(),
|
|
3302
3429
|
widgets: widgets(),
|
|
3303
3430
|
rootSchema: {},
|
|
3304
|
-
formContext: {}
|
|
3431
|
+
formContext: {},
|
|
3432
|
+
translateString: utils.englishStringTranslator
|
|
3305
3433
|
};
|
|
3306
3434
|
}
|
|
3307
3435
|
|
|
@@ -3324,7 +3452,7 @@
|
|
|
3324
3452
|
_this.formElement = void 0;
|
|
3325
3453
|
_this.getUsedFormData = function (formData, fields) {
|
|
3326
3454
|
// For the case of a single input form
|
|
3327
|
-
if (fields.length === 0 && typeof formData !==
|
|
3455
|
+
if (fields.length === 0 && typeof formData !== 'object') {
|
|
3328
3456
|
return formData;
|
|
3329
3457
|
}
|
|
3330
3458
|
// _pick has incorrect type definition, it works with string[][], because lodash/hasIn supports it
|
|
@@ -3345,22 +3473,22 @@
|
|
|
3345
3473
|
paths = [[]];
|
|
3346
3474
|
}
|
|
3347
3475
|
Object.keys(_obj).forEach(function (key) {
|
|
3348
|
-
if (typeof _obj[key] ===
|
|
3476
|
+
if (typeof _obj[key] === 'object') {
|
|
3349
3477
|
var newPaths = paths.map(function (path) {
|
|
3350
3478
|
return [].concat(path, [key]);
|
|
3351
3479
|
});
|
|
3352
3480
|
// If an object is marked with additionalProperties, all its keys are valid
|
|
3353
|
-
if (_obj[key][utils.RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][utils.NAME_KEY] !==
|
|
3481
|
+
if (_obj[key][utils.RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][utils.NAME_KEY] !== '') {
|
|
3354
3482
|
acc.push(_obj[key][utils.NAME_KEY]);
|
|
3355
3483
|
} else {
|
|
3356
3484
|
getAllPaths(_obj[key], acc, newPaths);
|
|
3357
3485
|
}
|
|
3358
|
-
} else if (key === utils.NAME_KEY && _obj[key] !==
|
|
3486
|
+
} else if (key === utils.NAME_KEY && _obj[key] !== '') {
|
|
3359
3487
|
paths.forEach(function (path) {
|
|
3360
3488
|
var formValue = get__default["default"](formData, path);
|
|
3361
3489
|
// adds path to fieldNames if it points to a value
|
|
3362
3490
|
// or an empty object/array
|
|
3363
|
-
if (typeof formValue !==
|
|
3491
|
+
if (typeof formValue !== 'object' || isEmpty__default["default"](formValue)) {
|
|
3364
3492
|
acc.push(path);
|
|
3365
3493
|
}
|
|
3366
3494
|
});
|
|
@@ -3393,7 +3521,7 @@
|
|
|
3393
3521
|
var newFormData = formData;
|
|
3394
3522
|
if (omitExtraData === true && liveOmit === true) {
|
|
3395
3523
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3396
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3524
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
3397
3525
|
var fieldNames = _this.getFieldNames(pathSchema, formData);
|
|
3398
3526
|
newFormData = _this.getUsedFormData(formData, fieldNames);
|
|
3399
3527
|
state = {
|
|
@@ -3419,7 +3547,7 @@
|
|
|
3419
3547
|
schemaValidationErrorSchema: schemaValidationErrorSchema
|
|
3420
3548
|
};
|
|
3421
3549
|
} else if (!noValidate && newErrorSchema) {
|
|
3422
|
-
var _errorSchema = extraErrors ? utils.mergeObjects(newErrorSchema, extraErrors,
|
|
3550
|
+
var _errorSchema = extraErrors ? utils.mergeObjects(newErrorSchema, extraErrors, 'preventDuplicates') : newErrorSchema;
|
|
3423
3551
|
state = {
|
|
3424
3552
|
formData: newFormData,
|
|
3425
3553
|
errorSchema: _errorSchema,
|
|
@@ -3459,7 +3587,7 @@
|
|
|
3459
3587
|
schemaUtils = _this$state2.schemaUtils;
|
|
3460
3588
|
if (omitExtraData === true) {
|
|
3461
3589
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, newFormData);
|
|
3462
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3590
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', newFormData);
|
|
3463
3591
|
var fieldNames = _this.getFieldNames(pathSchema, newFormData);
|
|
3464
3592
|
newFormData = _this.getUsedFormData(newFormData, fieldNames);
|
|
3465
3593
|
}
|
|
@@ -3478,20 +3606,20 @@
|
|
|
3478
3606
|
if (onSubmit) {
|
|
3479
3607
|
onSubmit(_extends({}, _this.state, {
|
|
3480
3608
|
formData: newFormData,
|
|
3481
|
-
status:
|
|
3609
|
+
status: 'submitted'
|
|
3482
3610
|
}), event);
|
|
3483
3611
|
}
|
|
3484
3612
|
});
|
|
3485
3613
|
}
|
|
3486
3614
|
};
|
|
3487
3615
|
if (!props.validator) {
|
|
3488
|
-
throw new Error(
|
|
3616
|
+
throw new Error('A validator is required for Form functionality to work');
|
|
3489
3617
|
}
|
|
3490
3618
|
_this.state = _this.getStateFromProps(props, props.formData);
|
|
3491
3619
|
if (_this.props.onChange && !utils.deepEquals(_this.state.formData, _this.props.formData)) {
|
|
3492
3620
|
_this.props.onChange(_this.state);
|
|
3493
3621
|
}
|
|
3494
|
-
_this.formElement = /*#__PURE__*/
|
|
3622
|
+
_this.formElement = /*#__PURE__*/react.createRef();
|
|
3495
3623
|
return _this;
|
|
3496
3624
|
}
|
|
3497
3625
|
/** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
|
|
@@ -3518,10 +3646,10 @@
|
|
|
3518
3646
|
*/;
|
|
3519
3647
|
_proto.getStateFromProps = function getStateFromProps(props, inputFormData) {
|
|
3520
3648
|
var state = this.state || {};
|
|
3521
|
-
var schema =
|
|
3522
|
-
var uiSchema = (
|
|
3523
|
-
var edit = typeof inputFormData !==
|
|
3524
|
-
var liveValidate =
|
|
3649
|
+
var schema = 'schema' in props ? props.schema : this.props.schema;
|
|
3650
|
+
var uiSchema = ('uiSchema' in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
3651
|
+
var edit = typeof inputFormData !== 'undefined';
|
|
3652
|
+
var liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
3525
3653
|
var mustValidate = edit && !props.noValidate && liveValidate;
|
|
3526
3654
|
var rootSchema = schema;
|
|
3527
3655
|
var schemaUtils = state.schemaUtils;
|
|
@@ -3570,7 +3698,7 @@
|
|
|
3570
3698
|
errorSchema = merged.errorSchema;
|
|
3571
3699
|
errors = merged.errors;
|
|
3572
3700
|
}
|
|
3573
|
-
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema[
|
|
3701
|
+
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema['ui:rootFieldId'], formData, props.idPrefix, props.idSeparator);
|
|
3574
3702
|
var nextState = {
|
|
3575
3703
|
schemaUtils: schemaUtils,
|
|
3576
3704
|
schema: schema,
|
|
@@ -3622,14 +3750,15 @@
|
|
|
3622
3750
|
uiSchema = _this$state3.uiSchema;
|
|
3623
3751
|
var formContext = this.props.formContext;
|
|
3624
3752
|
var options = utils.getUiOptions(uiSchema);
|
|
3625
|
-
var ErrorListTemplate = utils.getTemplate(
|
|
3753
|
+
var ErrorListTemplate = utils.getTemplate('ErrorListTemplate', registry, options);
|
|
3626
3754
|
if (errors && errors.length) {
|
|
3627
|
-
return
|
|
3755
|
+
return jsxRuntime.jsx(ErrorListTemplate, {
|
|
3628
3756
|
errors: errors,
|
|
3629
3757
|
errorSchema: errorSchema || {},
|
|
3630
3758
|
schema: schema,
|
|
3631
3759
|
uiSchema: uiSchema,
|
|
3632
|
-
formContext: formContext
|
|
3760
|
+
formContext: formContext,
|
|
3761
|
+
registry: registry
|
|
3633
3762
|
});
|
|
3634
3763
|
}
|
|
3635
3764
|
return null;
|
|
@@ -3642,12 +3771,14 @@
|
|
|
3642
3771
|
/** Returns the registry for the form */
|
|
3643
3772
|
_proto.getRegistry = function getRegistry() {
|
|
3644
3773
|
var _this$props$templates;
|
|
3774
|
+
var customTranslateString = this.props.translateString;
|
|
3645
3775
|
var schemaUtils = this.state.schemaUtils;
|
|
3646
3776
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3647
3777
|
fields = _getDefaultRegistry.fields,
|
|
3648
3778
|
templates = _getDefaultRegistry.templates,
|
|
3649
3779
|
widgets = _getDefaultRegistry.widgets,
|
|
3650
|
-
formContext = _getDefaultRegistry.formContext
|
|
3780
|
+
formContext = _getDefaultRegistry.formContext,
|
|
3781
|
+
translateString = _getDefaultRegistry.translateString;
|
|
3651
3782
|
return {
|
|
3652
3783
|
fields: _extends({}, fields, this.props.fields),
|
|
3653
3784
|
templates: _extends({}, templates, this.props.templates, {
|
|
@@ -3656,13 +3787,14 @@
|
|
|
3656
3787
|
widgets: _extends({}, widgets, this.props.widgets),
|
|
3657
3788
|
rootSchema: this.props.schema,
|
|
3658
3789
|
formContext: this.props.formContext || formContext,
|
|
3659
|
-
schemaUtils: schemaUtils
|
|
3790
|
+
schemaUtils: schemaUtils,
|
|
3791
|
+
translateString: customTranslateString || translateString
|
|
3660
3792
|
};
|
|
3661
3793
|
}
|
|
3662
3794
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
3663
3795
|
_proto.submit = function submit() {
|
|
3664
3796
|
if (this.formElement.current) {
|
|
3665
|
-
this.formElement.current.dispatchEvent(new CustomEvent(
|
|
3797
|
+
this.formElement.current.dispatchEvent(new CustomEvent('submit', {
|
|
3666
3798
|
cancelable: true
|
|
3667
3799
|
}));
|
|
3668
3800
|
this.formElement.current.requestSubmit();
|
|
@@ -3677,12 +3809,12 @@
|
|
|
3677
3809
|
_proto.focusOnError = function focusOnError(error) {
|
|
3678
3810
|
var _this$props4 = this.props,
|
|
3679
3811
|
_this$props4$idPrefix = _this$props4.idPrefix,
|
|
3680
|
-
idPrefix = _this$props4$idPrefix === void 0 ?
|
|
3812
|
+
idPrefix = _this$props4$idPrefix === void 0 ? 'root' : _this$props4$idPrefix,
|
|
3681
3813
|
_this$props4$idSepara = _this$props4.idSeparator,
|
|
3682
|
-
idSeparator = _this$props4$idSepara === void 0 ?
|
|
3814
|
+
idSeparator = _this$props4$idSepara === void 0 ? '_' : _this$props4$idSepara;
|
|
3683
3815
|
var property = error.property;
|
|
3684
3816
|
var path = _toPath__default["default"](property);
|
|
3685
|
-
if (path[0] ===
|
|
3817
|
+
if (path[0] === '') {
|
|
3686
3818
|
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3687
3819
|
path[0] = idPrefix;
|
|
3688
3820
|
} else {
|
|
@@ -3734,7 +3866,7 @@
|
|
|
3734
3866
|
if (onError) {
|
|
3735
3867
|
onError(errors);
|
|
3736
3868
|
} else {
|
|
3737
|
-
console.error(
|
|
3869
|
+
console.error('Form validation failed', errors);
|
|
3738
3870
|
}
|
|
3739
3871
|
});
|
|
3740
3872
|
return false;
|
|
@@ -3751,7 +3883,7 @@
|
|
|
3751
3883
|
idPrefix = _this$props6.idPrefix,
|
|
3752
3884
|
idSeparator = _this$props6.idSeparator,
|
|
3753
3885
|
_this$props6$classNam = _this$props6.className,
|
|
3754
|
-
className = _this$props6$classNam === void 0 ?
|
|
3886
|
+
className = _this$props6$classNam === void 0 ? '' : _this$props6$classNam,
|
|
3755
3887
|
tagName = _this$props6.tagName,
|
|
3756
3888
|
name = _this$props6.name,
|
|
3757
3889
|
method = _this$props6.method,
|
|
@@ -3768,7 +3900,7 @@
|
|
|
3768
3900
|
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
3769
3901
|
formContext = _this$props6.formContext,
|
|
3770
3902
|
_this$props6$showErro = _this$props6.showErrorList,
|
|
3771
|
-
showErrorList = _this$props6$showErro === void 0 ?
|
|
3903
|
+
showErrorList = _this$props6$showErro === void 0 ? 'top' : _this$props6$showErro,
|
|
3772
3904
|
_internalFormWrapper = _this$props6._internalFormWrapper;
|
|
3773
3905
|
var _this$state4 = this.state,
|
|
3774
3906
|
schema = _this$state4.schema,
|
|
@@ -3783,9 +3915,9 @@
|
|
|
3783
3915
|
// PropTypes.elementType to use for the inner tag, so we'll need to pass `tagName` along if it is provided.
|
|
3784
3916
|
// NOTE, the `as` prop is native to `semantic-ui` and is emulated in the `material-ui` theme
|
|
3785
3917
|
var as = _internalFormWrapper ? tagName : undefined;
|
|
3786
|
-
var FormTag = _internalFormWrapper || tagName ||
|
|
3787
|
-
return
|
|
3788
|
-
className: className ? className :
|
|
3918
|
+
var FormTag = _internalFormWrapper || tagName || 'form';
|
|
3919
|
+
return jsxRuntime.jsxs(FormTag, {
|
|
3920
|
+
className: className ? className : 'rjsf',
|
|
3789
3921
|
id: id,
|
|
3790
3922
|
name: name,
|
|
3791
3923
|
method: method,
|
|
@@ -3797,35 +3929,36 @@
|
|
|
3797
3929
|
noValidate: noHtml5Validate,
|
|
3798
3930
|
onSubmit: this.onSubmit,
|
|
3799
3931
|
as: as,
|
|
3800
|
-
ref: this.formElement
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3932
|
+
ref: this.formElement,
|
|
3933
|
+
children: [showErrorList === 'top' && this.renderErrors(registry), jsxRuntime.jsx(_SchemaField, {
|
|
3934
|
+
name: '',
|
|
3935
|
+
schema: schema,
|
|
3936
|
+
uiSchema: uiSchema,
|
|
3937
|
+
errorSchema: errorSchema,
|
|
3938
|
+
idSchema: idSchema,
|
|
3939
|
+
idPrefix: idPrefix,
|
|
3940
|
+
idSeparator: idSeparator,
|
|
3941
|
+
formContext: formContext,
|
|
3942
|
+
formData: formData,
|
|
3943
|
+
onChange: this.onChange,
|
|
3944
|
+
onBlur: this.onBlur,
|
|
3945
|
+
onFocus: this.onFocus,
|
|
3946
|
+
registry: registry,
|
|
3947
|
+
disabled: disabled,
|
|
3948
|
+
readonly: readonly
|
|
3949
|
+
}), children ? children : jsxRuntime.jsx(SubmitButton, {
|
|
3950
|
+
uiSchema: uiSchema,
|
|
3951
|
+
registry: registry
|
|
3952
|
+
}), showErrorList === 'bottom' && this.renderErrors(registry)]
|
|
3953
|
+
});
|
|
3821
3954
|
};
|
|
3822
3955
|
return Form;
|
|
3823
|
-
}(
|
|
3956
|
+
}(react.Component);
|
|
3824
3957
|
|
|
3825
3958
|
var _excluded = ["fields", "widgets", "templates"];
|
|
3826
3959
|
/** A Higher-Order component that creates a wrapper around a `Form` with the overrides from the `WithThemeProps` */
|
|
3827
3960
|
function withTheme(themeProps) {
|
|
3828
|
-
return /*#__PURE__*/
|
|
3961
|
+
return /*#__PURE__*/react.forwardRef(function (_ref, ref) {
|
|
3829
3962
|
var _themeProps$templates, _templates;
|
|
3830
3963
|
var fields = _ref.fields,
|
|
3831
3964
|
widgets = _ref.widgets,
|
|
@@ -3836,7 +3969,7 @@
|
|
|
3836
3969
|
templates = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.templates, templates, {
|
|
3837
3970
|
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)
|
|
3838
3971
|
});
|
|
3839
|
-
return
|
|
3972
|
+
return jsxRuntime.jsx(Form, _extends({}, themeProps, directProps, {
|
|
3840
3973
|
fields: fields,
|
|
3841
3974
|
widgets: widgets,
|
|
3842
3975
|
templates: templates,
|