@rjsf/core 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +183 -183
- package/README.md +1 -1
- package/dist/core.cjs.development.js +1017 -826
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +983 -792
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +1017 -828
- package/dist/core.umd.development.js.map +1 -1
- package/dist/core.umd.production.min.js +1 -1
- package/dist/core.umd.production.min.js.map +1 -1
- package/dist/index.d.ts +24 -17
- package/package.json +12 -12
|
@@ -2,33 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
6
7
|
var utils = require('@rjsf/utils');
|
|
7
8
|
var get = require('lodash/get');
|
|
8
9
|
var isEmpty = require('lodash/isEmpty');
|
|
9
10
|
var _pick = require('lodash/pick');
|
|
10
11
|
var _toPath = require('lodash/toPath');
|
|
12
|
+
var cloneDeep = require('lodash/cloneDeep');
|
|
11
13
|
var isObject = require('lodash/isObject');
|
|
12
14
|
var set = require('lodash/set');
|
|
13
15
|
var nanoid = require('nanoid');
|
|
14
16
|
var omit = require('lodash/omit');
|
|
17
|
+
var Markdown = require('markdown-to-jsx');
|
|
15
18
|
var has = require('lodash/has');
|
|
16
19
|
var unset = require('lodash/unset');
|
|
17
|
-
var Markdown = require('markdown-to-jsx');
|
|
18
20
|
|
|
19
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
22
|
|
|
21
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
23
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
23
24
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
24
25
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
25
26
|
var _toPath__default = /*#__PURE__*/_interopDefaultLegacy(_toPath);
|
|
27
|
+
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
26
28
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
27
29
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
28
30
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
31
|
+
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
29
32
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
30
33
|
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
31
|
-
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
32
34
|
|
|
33
35
|
function _defineProperties(target, props) {
|
|
34
36
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -165,6 +167,31 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
165
167
|
_this._handleAddClick(event, index);
|
|
166
168
|
};
|
|
167
169
|
};
|
|
170
|
+
_this.onCopyIndexClick = function (index) {
|
|
171
|
+
return function (event) {
|
|
172
|
+
if (event) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
}
|
|
175
|
+
var onChange = _this.props.onChange;
|
|
176
|
+
var keyedFormData = _this.state.keyedFormData;
|
|
177
|
+
var newKeyedFormDataRow = {
|
|
178
|
+
key: generateRowId(),
|
|
179
|
+
item: cloneDeep__default["default"](keyedFormData[index].item)
|
|
180
|
+
};
|
|
181
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
182
|
+
if (index !== undefined) {
|
|
183
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
184
|
+
} else {
|
|
185
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
186
|
+
}
|
|
187
|
+
_this.setState({
|
|
188
|
+
keyedFormData: newKeyedFormData,
|
|
189
|
+
updatedKeyedFormData: true
|
|
190
|
+
}, function () {
|
|
191
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
};
|
|
168
195
|
_this.onDropIndexClick = function (index) {
|
|
169
196
|
return function (event) {
|
|
170
197
|
if (event) {
|
|
@@ -249,7 +276,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
249
276
|
var newFormData = arrayData.map(function (item, i) {
|
|
250
277
|
// We need to treat undefined items as nulls to have validation.
|
|
251
278
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
252
|
-
var jsonValue = typeof value ===
|
|
279
|
+
var jsonValue = typeof value === 'undefined' ? null : value;
|
|
253
280
|
return index === i ? jsonValue : item;
|
|
254
281
|
});
|
|
255
282
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends2 = {}, _extends2[index] = newErrorSchema, _extends2)), id);
|
|
@@ -309,10 +336,10 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
309
336
|
if (Array.isArray(itemSchema.type)) {
|
|
310
337
|
// While we don't yet support composite/nullable jsonschema types, it's
|
|
311
338
|
// future-proof to check for requirement against these.
|
|
312
|
-
return !itemSchema.type.includes(
|
|
339
|
+
return !itemSchema.type.includes('null');
|
|
313
340
|
}
|
|
314
341
|
// All non-null array item types are inherently required by design
|
|
315
|
-
return itemSchema.type !==
|
|
342
|
+
return itemSchema.type !== 'null';
|
|
316
343
|
}
|
|
317
344
|
/** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
|
|
318
345
|
* then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
|
|
@@ -324,8 +351,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
324
351
|
_proto.canAddItem = function canAddItem(formItems) {
|
|
325
352
|
var _this$props6 = this.props,
|
|
326
353
|
schema = _this$props6.schema,
|
|
327
|
-
uiSchema = _this$props6.uiSchema
|
|
328
|
-
|
|
354
|
+
uiSchema = _this$props6.uiSchema,
|
|
355
|
+
registry = _this$props6.registry;
|
|
356
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, registry.globalUiOptions),
|
|
329
357
|
addable = _getUiOptions.addable;
|
|
330
358
|
if (addable !== false) {
|
|
331
359
|
// if ui:options.addable was not explicitly set to false, we can add
|
|
@@ -389,8 +417,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
389
417
|
translateString = registry.translateString;
|
|
390
418
|
if (!(utils.ITEMS_KEY in schema)) {
|
|
391
419
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
392
|
-
var UnsupportedFieldTemplate = utils.getTemplate(
|
|
393
|
-
return
|
|
420
|
+
var UnsupportedFieldTemplate = utils.getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
421
|
+
return jsxRuntime.jsx(UnsupportedFieldTemplate, {
|
|
394
422
|
schema: schema,
|
|
395
423
|
idSchema: idSchema,
|
|
396
424
|
reason: translateString(utils.TranslatableString.MissingItems),
|
|
@@ -436,7 +464,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
436
464
|
onFocus = _this$props8.onFocus,
|
|
437
465
|
idPrefix = _this$props8.idPrefix,
|
|
438
466
|
_this$props8$idSepara = _this$props8.idSeparator,
|
|
439
|
-
idSeparator = _this$props8$idSepara === void 0 ?
|
|
467
|
+
idSeparator = _this$props8$idSepara === void 0 ? '_' : _this$props8$idSepara,
|
|
440
468
|
rawErrors = _this$props8.rawErrors;
|
|
441
469
|
var keyedFormData = this.state.keyedFormData;
|
|
442
470
|
var title = schema.title === undefined ? name : schema.title;
|
|
@@ -491,8 +519,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
491
519
|
rawErrors: rawErrors,
|
|
492
520
|
registry: registry
|
|
493
521
|
};
|
|
494
|
-
var Template = utils.getTemplate(
|
|
495
|
-
return
|
|
522
|
+
var Template = utils.getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
523
|
+
return jsxRuntime.jsx(Template, _extends({}, arrayProps));
|
|
496
524
|
}
|
|
497
525
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
498
526
|
*/;
|
|
@@ -525,8 +553,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
525
553
|
widget = _getUiOptions2.widget,
|
|
526
554
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
527
555
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
528
|
-
return
|
|
556
|
+
return jsxRuntime.jsx(Widget, {
|
|
529
557
|
id: idSchema.$id,
|
|
558
|
+
name: name,
|
|
530
559
|
multiple: true,
|
|
531
560
|
onChange: this.onSelectChange,
|
|
532
561
|
onBlur: onBlur,
|
|
@@ -578,11 +607,12 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
578
607
|
var enumOptions = utils.optionsList(itemsSchema);
|
|
579
608
|
var _getUiOptions3 = utils.getUiOptions(uiSchema),
|
|
580
609
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
581
|
-
widget = _getUiOptions3$widget === void 0 ?
|
|
610
|
+
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
582
611
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
583
612
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
584
|
-
return
|
|
613
|
+
return jsxRuntime.jsx(Widget, {
|
|
585
614
|
id: idSchema.$id,
|
|
615
|
+
name: name,
|
|
586
616
|
multiple: true,
|
|
587
617
|
onChange: this.onSelectChange,
|
|
588
618
|
onBlur: onBlur,
|
|
@@ -631,12 +661,13 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
631
661
|
formContext = registry.formContext;
|
|
632
662
|
var _getUiOptions4 = utils.getUiOptions(uiSchema),
|
|
633
663
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
634
|
-
widget = _getUiOptions4$widget === void 0 ?
|
|
664
|
+
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
635
665
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
636
666
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
637
|
-
return
|
|
667
|
+
return jsxRuntime.jsx(Widget, {
|
|
638
668
|
options: options,
|
|
639
669
|
id: idSchema.$id,
|
|
670
|
+
name: name,
|
|
640
671
|
multiple: true,
|
|
641
672
|
onChange: this.onSelectChange,
|
|
642
673
|
onBlur: onBlur,
|
|
@@ -652,7 +683,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
652
683
|
formContext: formContext,
|
|
653
684
|
autofocus: autofocus,
|
|
654
685
|
rawErrors: rawErrors,
|
|
655
|
-
label:
|
|
686
|
+
label: ''
|
|
656
687
|
});
|
|
657
688
|
}
|
|
658
689
|
/** Renders an array that has a maximum limit of items
|
|
@@ -668,7 +699,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
668
699
|
errorSchema = _this$props12.errorSchema,
|
|
669
700
|
idPrefix = _this$props12.idPrefix,
|
|
670
701
|
_this$props12$idSepar = _this$props12.idSeparator,
|
|
671
|
-
idSeparator = _this$props12$idSepar === void 0 ?
|
|
702
|
+
idSeparator = _this$props12$idSepar === void 0 ? '_' : _this$props12$idSepar,
|
|
672
703
|
idSchema = _this$props12.idSchema,
|
|
673
704
|
name = _this$props12.name,
|
|
674
705
|
_this$props12$disable = _this$props12.disabled,
|
|
@@ -704,7 +735,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
704
735
|
var canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
705
736
|
var arrayProps = {
|
|
706
737
|
canAdd: canAdd,
|
|
707
|
-
className:
|
|
738
|
+
className: 'field field-array field-array-fixed-items',
|
|
708
739
|
disabled: disabled,
|
|
709
740
|
idSchema: idSchema,
|
|
710
741
|
formData: formData,
|
|
@@ -749,8 +780,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
749
780
|
formContext: formContext,
|
|
750
781
|
rawErrors: rawErrors
|
|
751
782
|
};
|
|
752
|
-
var Template = utils.getTemplate(
|
|
753
|
-
return
|
|
783
|
+
var Template = utils.getTemplate('ArrayFieldTemplate', registry, uiOptions);
|
|
784
|
+
return jsxRuntime.jsx(Template, _extends({}, arrayProps));
|
|
754
785
|
}
|
|
755
786
|
/** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
|
|
756
787
|
* back to the `ArrayFieldItemTemplate`.
|
|
@@ -764,10 +795,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
764
795
|
canAdd = props.canAdd,
|
|
765
796
|
_props$canRemove = props.canRemove,
|
|
766
797
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
_props$canMoveDown = props.canMoveDown,
|
|
770
|
-
canMoveDown = _props$canMoveDown === void 0 ? true : _props$canMoveDown,
|
|
798
|
+
canMoveUp = props.canMoveUp,
|
|
799
|
+
canMoveDown = props.canMoveDown,
|
|
771
800
|
itemSchema = props.itemSchema,
|
|
772
801
|
itemData = props.itemData,
|
|
773
802
|
itemUiSchema = props.itemUiSchema,
|
|
@@ -789,16 +818,20 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
789
818
|
formContext = _this$props13.formContext;
|
|
790
819
|
var _registry$fields = registry.fields,
|
|
791
820
|
ArraySchemaField = _registry$fields.ArraySchemaField,
|
|
792
|
-
SchemaField = _registry$fields.SchemaField
|
|
821
|
+
SchemaField = _registry$fields.SchemaField,
|
|
822
|
+
globalUiOptions = registry.globalUiOptions;
|
|
793
823
|
var ItemSchemaField = ArraySchemaField || SchemaField;
|
|
794
|
-
var _getUiOptions5 = utils.getUiOptions(uiSchema),
|
|
824
|
+
var _getUiOptions5 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
795
825
|
_getUiOptions5$ordera = _getUiOptions5.orderable,
|
|
796
826
|
orderable = _getUiOptions5$ordera === void 0 ? true : _getUiOptions5$ordera,
|
|
797
827
|
_getUiOptions5$remova = _getUiOptions5.removable,
|
|
798
|
-
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova
|
|
828
|
+
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova,
|
|
829
|
+
_getUiOptions5$copyab = _getUiOptions5.copyable,
|
|
830
|
+
copyable = _getUiOptions5$copyab === void 0 ? false : _getUiOptions5$copyab;
|
|
799
831
|
var has = {
|
|
800
832
|
moveUp: orderable && canMoveUp,
|
|
801
833
|
moveDown: orderable && canMoveDown,
|
|
834
|
+
copy: copyable && canAdd,
|
|
802
835
|
remove: removable && canRemove,
|
|
803
836
|
toolbar: false
|
|
804
837
|
};
|
|
@@ -806,7 +839,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
806
839
|
return has[key];
|
|
807
840
|
});
|
|
808
841
|
return {
|
|
809
|
-
children:
|
|
842
|
+
children: jsxRuntime.jsx(ItemSchemaField, {
|
|
810
843
|
name: name,
|
|
811
844
|
index: index,
|
|
812
845
|
schema: itemSchema,
|
|
@@ -828,9 +861,10 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
828
861
|
autofocus: autofocus,
|
|
829
862
|
rawErrors: rawErrors
|
|
830
863
|
}),
|
|
831
|
-
className:
|
|
864
|
+
className: 'array-item',
|
|
832
865
|
disabled: disabled,
|
|
833
866
|
canAdd: canAdd,
|
|
867
|
+
hasCopy: has.copy,
|
|
834
868
|
hasToolbar: has.toolbar,
|
|
835
869
|
hasMoveUp: has.moveUp,
|
|
836
870
|
hasMoveDown: has.moveDown,
|
|
@@ -839,6 +873,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
839
873
|
totalItems: totalItems,
|
|
840
874
|
key: key,
|
|
841
875
|
onAddIndexClick: this.onAddIndexClick,
|
|
876
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
842
877
|
onDropIndexClick: this.onDropIndexClick,
|
|
843
878
|
onReorderClick: this.onReorderClick,
|
|
844
879
|
readonly: readonly,
|
|
@@ -854,11 +889,11 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
854
889
|
schema = _this$props14.schema,
|
|
855
890
|
registry = _this$props14.registry;
|
|
856
891
|
var translateString = registry.translateString;
|
|
857
|
-
return get__default["default"](schema, [utils.ITEMS_KEY,
|
|
892
|
+
return get__default["default"](schema, [utils.ITEMS_KEY, 'title'], get__default["default"](schema, [utils.ITEMS_KEY, 'description'], translateString(utils.TranslatableString.ArrayItemTitle)));
|
|
858
893
|
}
|
|
859
894
|
}]);
|
|
860
895
|
return ArrayField;
|
|
861
|
-
}(
|
|
896
|
+
}(react.Component);
|
|
862
897
|
|
|
863
898
|
var _excluded$8 = ["widget"];
|
|
864
899
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
@@ -887,7 +922,7 @@ function BooleanField(props) {
|
|
|
887
922
|
translateString = registry.translateString;
|
|
888
923
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
889
924
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
890
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
925
|
+
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
891
926
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
892
927
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
893
928
|
var yes = translateString(utils.TranslatableString.YesLabel);
|
|
@@ -912,7 +947,7 @@ function BooleanField(props) {
|
|
|
912
947
|
var schemaWithEnumNames = schema;
|
|
913
948
|
var enums = (_schema$enum = schema["enum"]) != null ? _schema$enum : [true, false];
|
|
914
949
|
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every(function (v) {
|
|
915
|
-
return typeof v ===
|
|
950
|
+
return typeof v === 'boolean';
|
|
916
951
|
})) {
|
|
917
952
|
enumOptions = [{
|
|
918
953
|
value: enums[0],
|
|
@@ -929,13 +964,14 @@ function BooleanField(props) {
|
|
|
929
964
|
});
|
|
930
965
|
}
|
|
931
966
|
}
|
|
932
|
-
return
|
|
967
|
+
return jsxRuntime.jsx(Widget, {
|
|
933
968
|
options: _extends({}, options, {
|
|
934
969
|
enumOptions: enumOptions
|
|
935
970
|
}),
|
|
936
971
|
schema: schema,
|
|
937
972
|
uiSchema: uiSchema,
|
|
938
973
|
id: idSchema.$id,
|
|
974
|
+
name: name,
|
|
939
975
|
onChange: onChange,
|
|
940
976
|
onFocus: onFocus,
|
|
941
977
|
onBlur: onBlur,
|
|
@@ -985,7 +1021,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
985
1021
|
if (newFormData && newOption) {
|
|
986
1022
|
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
987
1023
|
// so that only the root objects themselves are created without adding undefined children properties
|
|
988
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData,
|
|
1024
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
989
1025
|
}
|
|
990
1026
|
onChange(newFormData, undefined, _this.getFieldId());
|
|
991
1027
|
_this.setState({
|
|
@@ -1072,12 +1108,13 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1072
1108
|
var _this$props4 = this.props,
|
|
1073
1109
|
idSchema = _this$props4.idSchema,
|
|
1074
1110
|
schema = _this$props4.schema;
|
|
1075
|
-
return "" + idSchema.$id + (schema.oneOf ?
|
|
1111
|
+
return "" + idSchema.$id + (schema.oneOf ? '__oneof_select' : '__anyof_select');
|
|
1076
1112
|
}
|
|
1077
1113
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1078
1114
|
*/;
|
|
1079
1115
|
_proto.render = function render() {
|
|
1080
1116
|
var _this$props5 = this.props,
|
|
1117
|
+
name = _this$props5.name,
|
|
1081
1118
|
baseType = _this$props5.baseType,
|
|
1082
1119
|
_this$props5$disabled = _this$props5.disabled,
|
|
1083
1120
|
disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
|
|
@@ -1098,7 +1135,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1098
1135
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1099
1136
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1100
1137
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1101
|
-
widget = _getUiOptions$widget === void 0 ?
|
|
1138
|
+
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1102
1139
|
placeholder = _getUiOptions.placeholder,
|
|
1103
1140
|
autofocus = _getUiOptions.autofocus,
|
|
1104
1141
|
autocomplete = _getUiOptions.autocomplete,
|
|
@@ -1106,7 +1143,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1106
1143
|
title = _getUiOptions$title === void 0 ? schema.title : _getUiOptions$title,
|
|
1107
1144
|
uiOptions = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$7);
|
|
1108
1145
|
var Widget = utils.getWidget({
|
|
1109
|
-
type:
|
|
1146
|
+
type: 'number'
|
|
1110
1147
|
}, widget, widgets);
|
|
1111
1148
|
var rawErrors = get__default["default"](errorSchema, utils.ERRORS_KEY, []);
|
|
1112
1149
|
var fieldErrorSchema = omit__default["default"](errorSchema, [utils.ERRORS_KEY]);
|
|
@@ -1127,39 +1164,42 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1127
1164
|
value: index
|
|
1128
1165
|
};
|
|
1129
1166
|
});
|
|
1130
|
-
return
|
|
1131
|
-
className:
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1167
|
+
return jsxRuntime.jsxs("div", {
|
|
1168
|
+
className: 'panel panel-default panel-body',
|
|
1169
|
+
children: [jsxRuntime.jsx("div", {
|
|
1170
|
+
className: 'form-group',
|
|
1171
|
+
children: jsxRuntime.jsx(Widget, {
|
|
1172
|
+
id: this.getFieldId(),
|
|
1173
|
+
name: "" + name + (schema.oneOf ? '__oneof_select' : '__anyof_select'),
|
|
1174
|
+
schema: {
|
|
1175
|
+
type: 'number',
|
|
1176
|
+
"default": 0
|
|
1177
|
+
},
|
|
1178
|
+
onChange: this.onOptionChange,
|
|
1179
|
+
onBlur: onBlur,
|
|
1180
|
+
onFocus: onFocus,
|
|
1181
|
+
disabled: disabled || isEmpty__default["default"](enumOptions),
|
|
1182
|
+
multiple: false,
|
|
1183
|
+
rawErrors: rawErrors,
|
|
1184
|
+
errorSchema: fieldErrorSchema,
|
|
1185
|
+
value: selectedOption >= 0 ? selectedOption : undefined,
|
|
1186
|
+
options: _extends({
|
|
1187
|
+
enumOptions: enumOptions
|
|
1188
|
+
}, uiOptions),
|
|
1189
|
+
registry: registry,
|
|
1190
|
+
formContext: formContext,
|
|
1191
|
+
placeholder: placeholder,
|
|
1192
|
+
autocomplete: autocomplete,
|
|
1193
|
+
autofocus: autofocus,
|
|
1194
|
+
label: ''
|
|
1195
|
+
})
|
|
1196
|
+
}), option !== null && jsxRuntime.jsx(_SchemaField, _extends({}, this.props, {
|
|
1197
|
+
schema: optionSchema
|
|
1198
|
+
}))]
|
|
1199
|
+
});
|
|
1160
1200
|
};
|
|
1161
1201
|
return AnyOfField;
|
|
1162
|
-
}(
|
|
1202
|
+
}(react.Component);
|
|
1163
1203
|
|
|
1164
1204
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
1165
1205
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
@@ -1193,7 +1233,7 @@ function NumberField(props) {
|
|
|
1193
1233
|
onChange = props.onChange,
|
|
1194
1234
|
formData = props.formData,
|
|
1195
1235
|
initialValue = props.value;
|
|
1196
|
-
var _useState =
|
|
1236
|
+
var _useState = react.useState(initialValue),
|
|
1197
1237
|
lastValue = _useState[0],
|
|
1198
1238
|
setLastValue = _useState[1];
|
|
1199
1239
|
var StringField = registry.fields.StringField;
|
|
@@ -1202,32 +1242,32 @@ function NumberField(props) {
|
|
|
1202
1242
|
*
|
|
1203
1243
|
* @param value - The current value for the change occurring
|
|
1204
1244
|
*/
|
|
1205
|
-
var handleChange =
|
|
1245
|
+
var handleChange = react.useCallback(function (value) {
|
|
1206
1246
|
// Cache the original value in component state
|
|
1207
1247
|
setLastValue(value);
|
|
1208
1248
|
// Normalize decimals that don't start with a zero character in advance so
|
|
1209
1249
|
// that the rest of the normalization logic is simpler
|
|
1210
|
-
if (("" + value).charAt(0) ===
|
|
1250
|
+
if (("" + value).charAt(0) === '.') {
|
|
1211
1251
|
value = "0" + value;
|
|
1212
1252
|
}
|
|
1213
1253
|
// Check that the value is a string (this can happen if the widget used is a
|
|
1214
1254
|
// <select>, due to an enum declaration etc) then, if the value ends in a
|
|
1215
1255
|
// trailing decimal point or multiple zeroes, strip the trailing values
|
|
1216
|
-
var processed = typeof value ===
|
|
1256
|
+
var processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix) ? utils.asNumber(value.replace(trailingCharMatcher, '')) : utils.asNumber(value);
|
|
1217
1257
|
onChange(processed);
|
|
1218
1258
|
}, [onChange]);
|
|
1219
|
-
if (typeof lastValue ===
|
|
1259
|
+
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
1220
1260
|
// Construct a regular expression that checks for a string that consists
|
|
1221
1261
|
// of the formData value suffixed with zero or one '.' characters and zero
|
|
1222
1262
|
// or more '0' characters
|
|
1223
|
-
var re = new RegExp(("" + value).replace(
|
|
1263
|
+
var re = new RegExp(("" + value).replace('.', '\\.') + '\\.?0*$');
|
|
1224
1264
|
// If the cached "lastValue" is a match, use that instead of the formData
|
|
1225
1265
|
// value to prevent the input value from changing in the UI
|
|
1226
1266
|
if (lastValue.match(re)) {
|
|
1227
1267
|
value = lastValue;
|
|
1228
1268
|
}
|
|
1229
1269
|
}
|
|
1230
|
-
return
|
|
1270
|
+
return jsxRuntime.jsx(StringField, _extends({}, props, {
|
|
1231
1271
|
formData: value,
|
|
1232
1272
|
onChange: handleChange
|
|
1233
1273
|
}));
|
|
@@ -1268,7 +1308,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1268
1308
|
// fields which are "mandated" by the schema, these fields can
|
|
1269
1309
|
// be set to undefined by clicking a "delete field" button, so
|
|
1270
1310
|
// set empty values to the empty string.
|
|
1271
|
-
value =
|
|
1311
|
+
value = '';
|
|
1272
1312
|
}
|
|
1273
1313
|
var newFormData = _extends({}, formData, (_extends2 = {}, _extends2[name] = value, _extends2));
|
|
1274
1314
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends3 = {}, _extends3[name] = newErrorSchema, _extends3)), id);
|
|
@@ -1286,10 +1326,12 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1286
1326
|
};
|
|
1287
1327
|
};
|
|
1288
1328
|
_this.getAvailableKey = function (preferredKey, formData) {
|
|
1289
|
-
var
|
|
1290
|
-
|
|
1329
|
+
var _this$props3 = _this.props,
|
|
1330
|
+
uiSchema = _this$props3.uiSchema,
|
|
1331
|
+
registry = _this$props3.registry;
|
|
1332
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, registry.globalUiOptions),
|
|
1291
1333
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1292
|
-
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ?
|
|
1334
|
+
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1293
1335
|
var index = 0;
|
|
1294
1336
|
var newKey = preferredKey;
|
|
1295
1337
|
while (has__default["default"](formData, newKey)) {
|
|
@@ -1303,10 +1345,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1303
1345
|
if (oldValue === value) {
|
|
1304
1346
|
return;
|
|
1305
1347
|
}
|
|
1306
|
-
var _this$
|
|
1307
|
-
formData = _this$
|
|
1308
|
-
onChange = _this$
|
|
1309
|
-
errorSchema = _this$
|
|
1348
|
+
var _this$props4 = _this.props,
|
|
1349
|
+
formData = _this$props4.formData,
|
|
1350
|
+
onChange = _this$props4.onChange,
|
|
1351
|
+
errorSchema = _this$props4.errorSchema;
|
|
1310
1352
|
value = _this.getAvailableKey(value, formData);
|
|
1311
1353
|
var newFormData = _extends({}, formData);
|
|
1312
1354
|
var newKeys = (_newKeys = {}, _newKeys[oldValue] = value, _newKeys);
|
|
@@ -1327,10 +1369,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1327
1369
|
if (!schema.additionalProperties) {
|
|
1328
1370
|
return;
|
|
1329
1371
|
}
|
|
1330
|
-
var _this$
|
|
1331
|
-
formData = _this$
|
|
1332
|
-
onChange = _this$
|
|
1333
|
-
registry = _this$
|
|
1372
|
+
var _this$props5 = _this.props,
|
|
1373
|
+
formData = _this$props5.formData,
|
|
1374
|
+
onChange = _this$props5.onChange,
|
|
1375
|
+
registry = _this$props5.registry;
|
|
1334
1376
|
var newFormData = _extends({}, formData);
|
|
1335
1377
|
var type = undefined;
|
|
1336
1378
|
if (isObject__default["default"](schema.additionalProperties)) {
|
|
@@ -1344,10 +1386,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1344
1386
|
type = apSchema.type;
|
|
1345
1387
|
}
|
|
1346
1388
|
if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
|
|
1347
|
-
type =
|
|
1389
|
+
type = 'object';
|
|
1348
1390
|
}
|
|
1349
1391
|
}
|
|
1350
|
-
var newKey = _this.getAvailableKey(
|
|
1392
|
+
var newKey = _this.getAvailableKey('newKey', newFormData);
|
|
1351
1393
|
// Cast this to make the `set` work properly
|
|
1352
1394
|
set__default["default"](newFormData, newKey, _this.getDefaultValue(type));
|
|
1353
1395
|
onChange(newFormData);
|
|
@@ -1380,17 +1422,17 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1380
1422
|
_proto.getDefaultValue = function getDefaultValue(type) {
|
|
1381
1423
|
var translateString = this.props.registry.translateString;
|
|
1382
1424
|
switch (type) {
|
|
1383
|
-
case
|
|
1425
|
+
case 'array':
|
|
1384
1426
|
return [];
|
|
1385
|
-
case
|
|
1427
|
+
case 'boolean':
|
|
1386
1428
|
return false;
|
|
1387
|
-
case
|
|
1429
|
+
case 'null':
|
|
1388
1430
|
return null;
|
|
1389
|
-
case
|
|
1431
|
+
case 'number':
|
|
1390
1432
|
return 0;
|
|
1391
|
-
case
|
|
1433
|
+
case 'object':
|
|
1392
1434
|
return {};
|
|
1393
|
-
case
|
|
1435
|
+
case 'string':
|
|
1394
1436
|
default:
|
|
1395
1437
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1396
1438
|
return translateString(utils.TranslatableString.NewStringDefault);
|
|
@@ -1405,60 +1447,67 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1405
1447
|
*/
|
|
1406
1448
|
_proto.render = function render() {
|
|
1407
1449
|
var _this2 = this;
|
|
1408
|
-
var _this$
|
|
1409
|
-
rawSchema = _this$
|
|
1410
|
-
_this$
|
|
1411
|
-
uiSchema = _this$
|
|
1412
|
-
formData = _this$
|
|
1413
|
-
errorSchema = _this$
|
|
1414
|
-
idSchema = _this$
|
|
1415
|
-
name = _this$
|
|
1416
|
-
_this$
|
|
1417
|
-
required = _this$
|
|
1418
|
-
_this$
|
|
1419
|
-
disabled = _this$
|
|
1420
|
-
_this$
|
|
1421
|
-
readonly = _this$
|
|
1422
|
-
hideError = _this$
|
|
1423
|
-
idPrefix = _this$
|
|
1424
|
-
idSeparator = _this$
|
|
1425
|
-
onBlur = _this$
|
|
1426
|
-
onFocus = _this$
|
|
1427
|
-
registry = _this$
|
|
1450
|
+
var _this$props6 = this.props,
|
|
1451
|
+
rawSchema = _this$props6.schema,
|
|
1452
|
+
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
1453
|
+
uiSchema = _this$props6$uiSchema === void 0 ? {} : _this$props6$uiSchema,
|
|
1454
|
+
formData = _this$props6.formData,
|
|
1455
|
+
errorSchema = _this$props6.errorSchema,
|
|
1456
|
+
idSchema = _this$props6.idSchema,
|
|
1457
|
+
name = _this$props6.name,
|
|
1458
|
+
_this$props6$required = _this$props6.required,
|
|
1459
|
+
required = _this$props6$required === void 0 ? false : _this$props6$required,
|
|
1460
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1461
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1462
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
1463
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
1464
|
+
hideError = _this$props6.hideError,
|
|
1465
|
+
idPrefix = _this$props6.idPrefix,
|
|
1466
|
+
idSeparator = _this$props6.idSeparator,
|
|
1467
|
+
onBlur = _this$props6.onBlur,
|
|
1468
|
+
onFocus = _this$props6.onFocus,
|
|
1469
|
+
registry = _this$props6.registry;
|
|
1428
1470
|
var fields = registry.fields,
|
|
1429
1471
|
formContext = registry.formContext,
|
|
1430
|
-
schemaUtils = registry.schemaUtils
|
|
1472
|
+
schemaUtils = registry.schemaUtils,
|
|
1473
|
+
translateString = registry.translateString;
|
|
1431
1474
|
var SchemaField = fields.SchemaField;
|
|
1432
1475
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1433
1476
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1434
1477
|
var _schema$properties = schema.properties,
|
|
1435
1478
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1436
|
-
var title = schema.title === undefined ? name : schema.title;
|
|
1479
|
+
var title = uiOptions.title || (schema.title === undefined ? name : schema.title);
|
|
1437
1480
|
var description = uiOptions.description || schema.description;
|
|
1438
1481
|
var orderedProperties;
|
|
1439
1482
|
try {
|
|
1440
1483
|
var properties = Object.keys(schemaProperties);
|
|
1441
1484
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1442
1485
|
} catch (err) {
|
|
1443
|
-
return
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1486
|
+
return jsxRuntime.jsxs("div", {
|
|
1487
|
+
children: [jsxRuntime.jsx("p", {
|
|
1488
|
+
className: 'config-error',
|
|
1489
|
+
style: {
|
|
1490
|
+
color: 'red'
|
|
1491
|
+
},
|
|
1492
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
1493
|
+
children: translateString(utils.TranslatableString.InvalidObjectField, [name || 'root', err.message])
|
|
1494
|
+
})
|
|
1495
|
+
}), jsxRuntime.jsx("pre", {
|
|
1496
|
+
children: JSON.stringify(schema)
|
|
1497
|
+
})]
|
|
1498
|
+
});
|
|
1449
1499
|
}
|
|
1450
|
-
var Template = utils.getTemplate(
|
|
1500
|
+
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1451
1501
|
var templateProps = {
|
|
1452
|
-
title:
|
|
1502
|
+
title: title,
|
|
1453
1503
|
description: description,
|
|
1454
1504
|
properties: orderedProperties.map(function (name) {
|
|
1455
1505
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
1456
1506
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
1457
|
-
var hidden = utils.getUiOptions(fieldUiSchema).widget ===
|
|
1507
|
+
var hidden = utils.getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
1458
1508
|
var fieldIdSchema = get__default["default"](idSchema, [name], {});
|
|
1459
1509
|
return {
|
|
1460
|
-
content:
|
|
1461
|
-
key: name,
|
|
1510
|
+
content: jsxRuntime.jsx(SchemaField, {
|
|
1462
1511
|
name: name,
|
|
1463
1512
|
required: _this2.isRequired(name),
|
|
1464
1513
|
schema: get__default["default"](schema, [utils.PROPERTIES_KEY, name], {}),
|
|
@@ -1479,7 +1528,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1479
1528
|
readonly: readonly,
|
|
1480
1529
|
hideError: hideError,
|
|
1481
1530
|
onDropPropertyClick: _this2.onDropPropertyClick
|
|
1482
|
-
}),
|
|
1531
|
+
}, name),
|
|
1483
1532
|
name: name,
|
|
1484
1533
|
readonly: readonly,
|
|
1485
1534
|
disabled: disabled,
|
|
@@ -1497,23 +1546,23 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1497
1546
|
formContext: formContext,
|
|
1498
1547
|
registry: registry
|
|
1499
1548
|
};
|
|
1500
|
-
return
|
|
1549
|
+
return jsxRuntime.jsx(Template, _extends({}, templateProps, {
|
|
1501
1550
|
onAddClick: this.handleAddClick
|
|
1502
1551
|
}));
|
|
1503
1552
|
};
|
|
1504
1553
|
return ObjectField;
|
|
1505
|
-
}(
|
|
1554
|
+
}(react.Component);
|
|
1506
1555
|
|
|
1507
1556
|
var _excluded$6 = ["__errors"];
|
|
1508
1557
|
/** The map of component type to FieldName */
|
|
1509
1558
|
var COMPONENT_TYPES = {
|
|
1510
|
-
array:
|
|
1511
|
-
"boolean":
|
|
1512
|
-
integer:
|
|
1513
|
-
number:
|
|
1514
|
-
object:
|
|
1515
|
-
string:
|
|
1516
|
-
"null":
|
|
1559
|
+
array: 'ArrayField',
|
|
1560
|
+
"boolean": 'BooleanField',
|
|
1561
|
+
integer: 'NumberField',
|
|
1562
|
+
number: 'NumberField',
|
|
1563
|
+
object: 'ObjectField',
|
|
1564
|
+
string: 'StringField',
|
|
1565
|
+
"null": 'NullField'
|
|
1517
1566
|
};
|
|
1518
1567
|
/** Computes and returns which `Field` implementation to return in order to render the field represented by the
|
|
1519
1568
|
* `schema`. The `uiOptions` are used to alter what potential `Field` implementation is actually returned. If no
|
|
@@ -1529,14 +1578,14 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1529
1578
|
var field = uiOptions.field;
|
|
1530
1579
|
var fields = registry.fields,
|
|
1531
1580
|
translateString = registry.translateString;
|
|
1532
|
-
if (typeof field ===
|
|
1581
|
+
if (typeof field === 'function') {
|
|
1533
1582
|
return field;
|
|
1534
1583
|
}
|
|
1535
|
-
if (typeof field ===
|
|
1584
|
+
if (typeof field === 'string' && field in fields) {
|
|
1536
1585
|
return fields[field];
|
|
1537
1586
|
}
|
|
1538
1587
|
var schemaType = utils.getSchemaType(schema);
|
|
1539
|
-
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType ||
|
|
1588
|
+
var type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
|
|
1540
1589
|
var componentName = COMPONENT_TYPES[type];
|
|
1541
1590
|
// If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
|
|
1542
1591
|
// render a field and let the MultiSchemaField component handle the form display
|
|
@@ -1546,8 +1595,8 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1546
1595
|
};
|
|
1547
1596
|
}
|
|
1548
1597
|
return componentName in fields ? fields[componentName] : function () {
|
|
1549
|
-
var UnsupportedFieldTemplate = utils.getTemplate(
|
|
1550
|
-
return
|
|
1598
|
+
var UnsupportedFieldTemplate = utils.getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
1599
|
+
return jsxRuntime.jsx(UnsupportedFieldTemplate, {
|
|
1551
1600
|
schema: schema,
|
|
1552
1601
|
idSchema: idSchema,
|
|
1553
1602
|
reason: translateString(utils.TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
@@ -1578,19 +1627,20 @@ function SchemaFieldRender(props) {
|
|
|
1578
1627
|
_props$wasPropertyKey = props.wasPropertyKeyModified,
|
|
1579
1628
|
wasPropertyKeyModified = _props$wasPropertyKey === void 0 ? false : _props$wasPropertyKey;
|
|
1580
1629
|
var formContext = registry.formContext,
|
|
1581
|
-
schemaUtils = registry.schemaUtils
|
|
1582
|
-
|
|
1583
|
-
var
|
|
1584
|
-
var
|
|
1585
|
-
var
|
|
1586
|
-
var
|
|
1630
|
+
schemaUtils = registry.schemaUtils,
|
|
1631
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1632
|
+
var uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1633
|
+
var FieldTemplate = utils.getTemplate('FieldTemplate', registry, uiOptions);
|
|
1634
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1635
|
+
var FieldHelpTemplate = utils.getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
1636
|
+
var FieldErrorTemplate = utils.getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
1587
1637
|
var schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1588
1638
|
var fieldId = _idSchema[utils.ID_KEY];
|
|
1589
1639
|
var idSchema = utils.mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
1590
1640
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
1591
1641
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
1592
1642
|
*/
|
|
1593
|
-
var handleFieldComponentChange =
|
|
1643
|
+
var handleFieldComponentChange = react.useCallback(function (formData, newErrorSchema, id) {
|
|
1594
1644
|
var theId = id || fieldId;
|
|
1595
1645
|
return onChange(formData, newErrorSchema, theId);
|
|
1596
1646
|
}, [fieldId, onChange]);
|
|
@@ -1604,16 +1654,16 @@ function SchemaFieldRender(props) {
|
|
|
1604
1654
|
if (Object.keys(schema).length === 0) {
|
|
1605
1655
|
return null;
|
|
1606
1656
|
}
|
|
1607
|
-
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1657
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1608
1658
|
var _ref = errorSchema || {},
|
|
1609
1659
|
__errors = _ref.__errors,
|
|
1610
1660
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1611
1661
|
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
1612
|
-
var fieldUiSchema = omit__default["default"](uiSchema, [
|
|
1662
|
+
var fieldUiSchema = omit__default["default"](uiSchema, ['ui:classNames', 'classNames', 'ui:style']);
|
|
1613
1663
|
if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
1614
|
-
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], [
|
|
1664
|
+
fieldUiSchema[utils.UI_OPTIONS_KEY] = omit__default["default"](fieldUiSchema[utils.UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
1615
1665
|
}
|
|
1616
|
-
var field =
|
|
1666
|
+
var field = jsxRuntime.jsx(FieldComponent, _extends({}, props, {
|
|
1617
1667
|
onChange: handleFieldComponentChange,
|
|
1618
1668
|
idSchema: idSchema,
|
|
1619
1669
|
schema: schema,
|
|
@@ -1634,12 +1684,12 @@ function SchemaFieldRender(props) {
|
|
|
1634
1684
|
} else {
|
|
1635
1685
|
label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1636
1686
|
}
|
|
1637
|
-
var description = uiOptions.description || props.schema.description || schema.description ||
|
|
1687
|
+
var description = uiOptions.description || props.schema.description || schema.description || '';
|
|
1638
1688
|
var help = uiOptions.help;
|
|
1639
|
-
var hidden = uiOptions.widget ===
|
|
1640
|
-
var classNames = [
|
|
1689
|
+
var hidden = uiOptions.widget === 'hidden';
|
|
1690
|
+
var classNames = ['form-group', 'field', "field-" + schema.type];
|
|
1641
1691
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1642
|
-
classNames.push(
|
|
1692
|
+
classNames.push('field-error has-error has-danger');
|
|
1643
1693
|
}
|
|
1644
1694
|
if (uiSchema !== null && uiSchema !== void 0 && uiSchema.classNames) {
|
|
1645
1695
|
{
|
|
@@ -1650,7 +1700,7 @@ function SchemaFieldRender(props) {
|
|
|
1650
1700
|
if (uiOptions.classNames) {
|
|
1651
1701
|
classNames.push(uiOptions.classNames);
|
|
1652
1702
|
}
|
|
1653
|
-
var helpComponent =
|
|
1703
|
+
var helpComponent = jsxRuntime.jsx(FieldHelpTemplate, {
|
|
1654
1704
|
help: help,
|
|
1655
1705
|
idSchema: idSchema,
|
|
1656
1706
|
schema: schema,
|
|
@@ -1658,7 +1708,7 @@ function SchemaFieldRender(props) {
|
|
|
1658
1708
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
1659
1709
|
registry: registry
|
|
1660
1710
|
});
|
|
1661
|
-
var errorsComponent = hideError ? undefined :
|
|
1711
|
+
var errorsComponent = hideError ? undefined : jsxRuntime.jsx(FieldErrorTemplate, {
|
|
1662
1712
|
errors: __errors,
|
|
1663
1713
|
errorSchema: errorSchema,
|
|
1664
1714
|
idSchema: idSchema,
|
|
@@ -1667,7 +1717,7 @@ function SchemaFieldRender(props) {
|
|
|
1667
1717
|
registry: registry
|
|
1668
1718
|
});
|
|
1669
1719
|
var fieldProps = {
|
|
1670
|
-
description:
|
|
1720
|
+
description: jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
1671
1721
|
id: utils.descriptionId(id),
|
|
1672
1722
|
description: description,
|
|
1673
1723
|
schema: schema,
|
|
@@ -1676,7 +1726,7 @@ function SchemaFieldRender(props) {
|
|
|
1676
1726
|
}),
|
|
1677
1727
|
rawDescription: description,
|
|
1678
1728
|
help: helpComponent,
|
|
1679
|
-
rawHelp: typeof help ===
|
|
1729
|
+
rawHelp: typeof help === 'string' ? help : undefined,
|
|
1680
1730
|
errors: errorsComponent,
|
|
1681
1731
|
rawErrors: hideError ? undefined : __errors,
|
|
1682
1732
|
id: id,
|
|
@@ -1690,7 +1740,7 @@ function SchemaFieldRender(props) {
|
|
|
1690
1740
|
readonly: readonly,
|
|
1691
1741
|
hideError: hideError,
|
|
1692
1742
|
displayLabel: displayLabel,
|
|
1693
|
-
classNames: classNames.join(
|
|
1743
|
+
classNames: classNames.join(' ').trim(),
|
|
1694
1744
|
style: uiOptions.style,
|
|
1695
1745
|
formContext: formContext,
|
|
1696
1746
|
formData: formData,
|
|
@@ -1700,68 +1750,72 @@ function SchemaFieldRender(props) {
|
|
|
1700
1750
|
};
|
|
1701
1751
|
var _AnyOfField = registry.fields.AnyOfField;
|
|
1702
1752
|
var _OneOfField = registry.fields.OneOfField;
|
|
1703
|
-
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[
|
|
1704
|
-
return
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1753
|
+
var isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:field']) && (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:fieldReplacesAnyOrOneOf']) === true;
|
|
1754
|
+
return jsxRuntime.jsx(FieldTemplate, _extends({}, fieldProps, {
|
|
1755
|
+
children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1756
|
+
children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsxRuntime.jsx(_AnyOfField, {
|
|
1757
|
+
name: name,
|
|
1758
|
+
disabled: disabled,
|
|
1759
|
+
readonly: readonly,
|
|
1760
|
+
hideError: hideError,
|
|
1761
|
+
errorSchema: errorSchema,
|
|
1762
|
+
formData: formData,
|
|
1763
|
+
formContext: formContext,
|
|
1764
|
+
idPrefix: idPrefix,
|
|
1765
|
+
idSchema: idSchema,
|
|
1766
|
+
idSeparator: idSeparator,
|
|
1767
|
+
onBlur: props.onBlur,
|
|
1768
|
+
onChange: props.onChange,
|
|
1769
|
+
onFocus: props.onFocus,
|
|
1770
|
+
options: schema.anyOf.map(function (_schema) {
|
|
1771
|
+
return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
|
|
1772
|
+
}),
|
|
1773
|
+
baseType: schema.type,
|
|
1774
|
+
registry: registry,
|
|
1775
|
+
schema: schema,
|
|
1776
|
+
uiSchema: uiSchema
|
|
1777
|
+
}), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && jsxRuntime.jsx(_OneOfField, {
|
|
1778
|
+
name: name,
|
|
1779
|
+
disabled: disabled,
|
|
1780
|
+
readonly: readonly,
|
|
1781
|
+
hideError: hideError,
|
|
1782
|
+
errorSchema: errorSchema,
|
|
1783
|
+
formData: formData,
|
|
1784
|
+
formContext: formContext,
|
|
1785
|
+
idPrefix: idPrefix,
|
|
1786
|
+
idSchema: idSchema,
|
|
1787
|
+
idSeparator: idSeparator,
|
|
1788
|
+
onBlur: props.onBlur,
|
|
1789
|
+
onChange: props.onChange,
|
|
1790
|
+
onFocus: props.onFocus,
|
|
1791
|
+
options: schema.oneOf.map(function (_schema) {
|
|
1792
|
+
return schemaUtils.retrieveSchema(isObject__default["default"](_schema) ? _schema : {}, formData);
|
|
1793
|
+
}),
|
|
1794
|
+
baseType: schema.type,
|
|
1795
|
+
registry: registry,
|
|
1796
|
+
schema: schema,
|
|
1797
|
+
uiSchema: uiSchema
|
|
1798
|
+
})]
|
|
1799
|
+
})
|
|
1800
|
+
}));
|
|
1747
1801
|
}
|
|
1748
1802
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
1749
1803
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
1750
1804
|
*/
|
|
1751
|
-
var SchemaField = /*#__PURE__*/function (
|
|
1752
|
-
_inheritsLoose(SchemaField,
|
|
1805
|
+
var SchemaField = /*#__PURE__*/function (_Component) {
|
|
1806
|
+
_inheritsLoose(SchemaField, _Component);
|
|
1753
1807
|
function SchemaField() {
|
|
1754
|
-
return
|
|
1808
|
+
return _Component.apply(this, arguments) || this;
|
|
1755
1809
|
}
|
|
1756
1810
|
var _proto = SchemaField.prototype;
|
|
1757
1811
|
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
1758
1812
|
return !utils.deepEquals(this.props, nextProps);
|
|
1759
1813
|
};
|
|
1760
1814
|
_proto.render = function render() {
|
|
1761
|
-
return
|
|
1815
|
+
return jsxRuntime.jsx(SchemaFieldRender, _extends({}, this.props));
|
|
1762
1816
|
};
|
|
1763
1817
|
return SchemaField;
|
|
1764
|
-
}(
|
|
1818
|
+
}(react.Component);
|
|
1765
1819
|
|
|
1766
1820
|
var _excluded$5 = ["widget", "placeholder"];
|
|
1767
1821
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
@@ -1792,7 +1846,7 @@ function StringField(props) {
|
|
|
1792
1846
|
formContext = registry.formContext,
|
|
1793
1847
|
schemaUtils = registry.schemaUtils;
|
|
1794
1848
|
var enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : undefined;
|
|
1795
|
-
var defaultWidget = enumOptions ?
|
|
1849
|
+
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1796
1850
|
if (format && utils.hasWidget(schema, format, widgets)) {
|
|
1797
1851
|
defaultWidget = format;
|
|
1798
1852
|
}
|
|
@@ -1800,16 +1854,17 @@ function StringField(props) {
|
|
|
1800
1854
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1801
1855
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1802
1856
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1803
|
-
placeholder = _getUiOptions$placeho === void 0 ?
|
|
1857
|
+
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1804
1858
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1805
1859
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
1806
|
-
return
|
|
1860
|
+
return jsxRuntime.jsx(Widget, {
|
|
1807
1861
|
options: _extends({}, options, {
|
|
1808
1862
|
enumOptions: enumOptions
|
|
1809
1863
|
}),
|
|
1810
1864
|
schema: schema,
|
|
1811
1865
|
uiSchema: uiSchema,
|
|
1812
1866
|
id: idSchema.$id,
|
|
1867
|
+
name: name,
|
|
1813
1868
|
label: title === undefined ? name : title,
|
|
1814
1869
|
value: formData,
|
|
1815
1870
|
onChange: onChange,
|
|
@@ -1834,7 +1889,7 @@ function StringField(props) {
|
|
|
1834
1889
|
function NullField(props) {
|
|
1835
1890
|
var formData = props.formData,
|
|
1836
1891
|
onChange = props.onChange;
|
|
1837
|
-
|
|
1892
|
+
react.useEffect(function () {
|
|
1838
1893
|
if (formData === undefined) {
|
|
1839
1894
|
onChange(null);
|
|
1840
1895
|
}
|
|
@@ -1874,8 +1929,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1874
1929
|
if (!description || !displayLabel) {
|
|
1875
1930
|
return null;
|
|
1876
1931
|
}
|
|
1877
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
1878
|
-
return
|
|
1932
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
1933
|
+
return jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
1879
1934
|
id: utils.descriptionId(idSchema),
|
|
1880
1935
|
description: description,
|
|
1881
1936
|
schema: schema,
|
|
@@ -1896,13 +1951,16 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1896
1951
|
hasMoveDown = props.hasMoveDown,
|
|
1897
1952
|
hasMoveUp = props.hasMoveUp,
|
|
1898
1953
|
hasRemove = props.hasRemove,
|
|
1954
|
+
hasCopy = props.hasCopy,
|
|
1899
1955
|
index = props.index,
|
|
1956
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
1900
1957
|
onDropIndexClick = props.onDropIndexClick,
|
|
1901
1958
|
onReorderClick = props.onReorderClick,
|
|
1902
1959
|
readonly = props.readonly,
|
|
1903
1960
|
registry = props.registry,
|
|
1904
1961
|
uiSchema = props.uiSchema;
|
|
1905
1962
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
1963
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
1906
1964
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
1907
1965
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
1908
1966
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -1910,39 +1968,49 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1910
1968
|
flex: 1,
|
|
1911
1969
|
paddingLeft: 6,
|
|
1912
1970
|
paddingRight: 6,
|
|
1913
|
-
fontWeight:
|
|
1971
|
+
fontWeight: 'bold'
|
|
1914
1972
|
};
|
|
1915
|
-
return
|
|
1916
|
-
className: className
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1973
|
+
return jsxRuntime.jsxs("div", {
|
|
1974
|
+
className: className,
|
|
1975
|
+
children: [jsxRuntime.jsx("div", {
|
|
1976
|
+
className: hasToolbar ? 'col-xs-9' : 'col-xs-12',
|
|
1977
|
+
children: children
|
|
1978
|
+
}), hasToolbar && jsxRuntime.jsx("div", {
|
|
1979
|
+
className: 'col-xs-3 array-item-toolbox',
|
|
1980
|
+
children: jsxRuntime.jsxs("div", {
|
|
1981
|
+
className: 'btn-group',
|
|
1982
|
+
style: {
|
|
1983
|
+
display: 'flex',
|
|
1984
|
+
justifyContent: 'space-around'
|
|
1985
|
+
},
|
|
1986
|
+
children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
|
|
1987
|
+
style: btnStyle,
|
|
1988
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
1989
|
+
onClick: onReorderClick(index, index - 1),
|
|
1990
|
+
uiSchema: uiSchema,
|
|
1991
|
+
registry: registry
|
|
1992
|
+
}), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
|
|
1993
|
+
style: btnStyle,
|
|
1994
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
1995
|
+
onClick: onReorderClick(index, index + 1),
|
|
1996
|
+
uiSchema: uiSchema,
|
|
1997
|
+
registry: registry
|
|
1998
|
+
}), hasCopy && jsxRuntime.jsx(CopyButton, {
|
|
1999
|
+
style: btnStyle,
|
|
2000
|
+
disabled: disabled || readonly,
|
|
2001
|
+
onClick: onCopyIndexClick(index),
|
|
2002
|
+
uiSchema: uiSchema,
|
|
2003
|
+
registry: registry
|
|
2004
|
+
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
2005
|
+
style: btnStyle,
|
|
2006
|
+
disabled: disabled || readonly,
|
|
2007
|
+
onClick: onDropIndexClick(index),
|
|
2008
|
+
uiSchema: uiSchema,
|
|
2009
|
+
registry: registry
|
|
2010
|
+
})]
|
|
2011
|
+
})
|
|
2012
|
+
})]
|
|
2013
|
+
});
|
|
1946
2014
|
}
|
|
1947
2015
|
|
|
1948
2016
|
var _excluded$4 = ["key"];
|
|
@@ -1964,42 +2032,42 @@ function ArrayFieldTemplate(props) {
|
|
|
1964
2032
|
schema = props.schema,
|
|
1965
2033
|
title = props.title;
|
|
1966
2034
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1967
|
-
var ArrayFieldDescriptionTemplate = utils.getTemplate(
|
|
1968
|
-
var ArrayFieldItemTemplate = utils.getTemplate(
|
|
1969
|
-
var ArrayFieldTitleTemplate = utils.getTemplate(
|
|
2035
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
2036
|
+
var ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
2037
|
+
var ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
1970
2038
|
// Button templates are not overridden in the uiSchema
|
|
1971
2039
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
1972
|
-
return
|
|
2040
|
+
return jsxRuntime.jsxs("fieldset", {
|
|
1973
2041
|
className: className,
|
|
1974
|
-
id: idSchema.$id
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
},
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
})
|
|
2042
|
+
id: idSchema.$id,
|
|
2043
|
+
children: [jsxRuntime.jsx(ArrayFieldTitleTemplate, {
|
|
2044
|
+
idSchema: idSchema,
|
|
2045
|
+
title: uiOptions.title || title,
|
|
2046
|
+
required: required,
|
|
2047
|
+
schema: schema,
|
|
2048
|
+
uiSchema: uiSchema,
|
|
2049
|
+
registry: registry
|
|
2050
|
+
}), jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
|
|
2051
|
+
idSchema: idSchema,
|
|
2052
|
+
description: uiOptions.description || schema.description,
|
|
2053
|
+
schema: schema,
|
|
2054
|
+
uiSchema: uiSchema,
|
|
2055
|
+
registry: registry
|
|
2056
|
+
}), jsxRuntime.jsx("div", {
|
|
2057
|
+
className: 'row array-item-list',
|
|
2058
|
+
children: items && items.map(function (_ref) {
|
|
2059
|
+
var key = _ref.key,
|
|
2060
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
2061
|
+
return jsxRuntime.jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
2062
|
+
})
|
|
2063
|
+
}), canAdd && jsxRuntime.jsx(AddButton, {
|
|
2064
|
+
className: 'array-item-add',
|
|
2065
|
+
onClick: onAddClick,
|
|
2066
|
+
disabled: disabled || readonly,
|
|
2067
|
+
uiSchema: uiSchema,
|
|
2068
|
+
registry: registry
|
|
2069
|
+
})]
|
|
2070
|
+
});
|
|
2003
2071
|
}
|
|
2004
2072
|
|
|
2005
2073
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
@@ -2020,8 +2088,8 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2020
2088
|
if (!title || !displayLabel) {
|
|
2021
2089
|
return null;
|
|
2022
2090
|
}
|
|
2023
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
2024
|
-
return
|
|
2091
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
2092
|
+
return jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2025
2093
|
id: utils.titleId(idSchema),
|
|
2026
2094
|
title: title,
|
|
2027
2095
|
required: required,
|
|
@@ -2031,7 +2099,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2031
2099
|
});
|
|
2032
2100
|
}
|
|
2033
2101
|
|
|
2034
|
-
var _excluded$3 = ["id", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2102
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2035
2103
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2036
2104
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2037
2105
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2047,6 +2115,7 @@ function BaseInputTemplate(props) {
|
|
|
2047
2115
|
onBlur = props.onBlur,
|
|
2048
2116
|
onFocus = props.onFocus,
|
|
2049
2117
|
onChange = props.onChange,
|
|
2118
|
+
onChangeOverride = props.onChangeOverride,
|
|
2050
2119
|
options = props.options,
|
|
2051
2120
|
schema = props.schema,
|
|
2052
2121
|
type = props.type,
|
|
@@ -2054,51 +2123,52 @@ function BaseInputTemplate(props) {
|
|
|
2054
2123
|
// Note: since React 15.2.0 we can't forward unknown element attributes, so we
|
|
2055
2124
|
// exclude the "options" and "schema" ones here.
|
|
2056
2125
|
if (!id) {
|
|
2057
|
-
console.log(
|
|
2126
|
+
console.log('No id for', props);
|
|
2058
2127
|
throw new Error("no id for props " + JSON.stringify(props));
|
|
2059
2128
|
}
|
|
2060
2129
|
var inputProps = _extends({}, rest, utils.getInputProps(schema, type, options));
|
|
2061
2130
|
var inputValue;
|
|
2062
|
-
if (inputProps.type ===
|
|
2063
|
-
inputValue = value || value === 0 ? value :
|
|
2131
|
+
if (inputProps.type === 'number' || inputProps.type === 'integer') {
|
|
2132
|
+
inputValue = value || value === 0 ? value : '';
|
|
2064
2133
|
} else {
|
|
2065
|
-
inputValue = value == null ?
|
|
2134
|
+
inputValue = value == null ? '' : value;
|
|
2066
2135
|
}
|
|
2067
|
-
var _onChange =
|
|
2136
|
+
var _onChange = react.useCallback(function (_ref) {
|
|
2068
2137
|
var value = _ref.target.value;
|
|
2069
|
-
return onChange(value ===
|
|
2138
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
2070
2139
|
}, [onChange, options]);
|
|
2071
|
-
var _onBlur =
|
|
2140
|
+
var _onBlur = react.useCallback(function (_ref2) {
|
|
2072
2141
|
var value = _ref2.target.value;
|
|
2073
2142
|
return onBlur(id, value);
|
|
2074
2143
|
}, [onBlur, id]);
|
|
2075
|
-
var _onFocus =
|
|
2144
|
+
var _onFocus = react.useCallback(function (_ref3) {
|
|
2076
2145
|
var value = _ref3.target.value;
|
|
2077
2146
|
return onFocus(id, value);
|
|
2078
2147
|
}, [onFocus, id]);
|
|
2079
|
-
return
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2148
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2149
|
+
children: [jsxRuntime.jsx("input", _extends({
|
|
2150
|
+
id: id,
|
|
2151
|
+
name: id,
|
|
2152
|
+
className: 'form-control',
|
|
2153
|
+
readOnly: readonly,
|
|
2154
|
+
disabled: disabled,
|
|
2155
|
+
autoFocus: autofocus,
|
|
2156
|
+
value: inputValue
|
|
2157
|
+
}, inputProps, {
|
|
2158
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
2159
|
+
onChange: onChangeOverride || _onChange,
|
|
2160
|
+
onBlur: _onBlur,
|
|
2161
|
+
onFocus: _onFocus,
|
|
2162
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
2163
|
+
})), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
|
|
2164
|
+
id: utils.examplesId(id),
|
|
2165
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
2166
|
+
return jsxRuntime.jsx("option", {
|
|
2167
|
+
value: example
|
|
2168
|
+
}, example);
|
|
2169
|
+
})
|
|
2170
|
+
}, "datalist_" + id)]
|
|
2171
|
+
});
|
|
2102
2172
|
}
|
|
2103
2173
|
|
|
2104
2174
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -2113,53 +2183,67 @@ function SubmitButton(_ref) {
|
|
|
2113
2183
|
if (norender) {
|
|
2114
2184
|
return null;
|
|
2115
2185
|
}
|
|
2116
|
-
return
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2186
|
+
return jsxRuntime.jsx("div", {
|
|
2187
|
+
children: jsxRuntime.jsx("button", _extends({
|
|
2188
|
+
type: 'submit'
|
|
2189
|
+
}, submitButtonProps, {
|
|
2190
|
+
className: "btn btn-info " + submitButtonProps.className,
|
|
2191
|
+
children: submitText
|
|
2192
|
+
}))
|
|
2193
|
+
});
|
|
2121
2194
|
}
|
|
2122
2195
|
|
|
2123
2196
|
var _excluded$2 = ["iconType", "icon", "className", "uiSchema", "registry"];
|
|
2124
2197
|
function IconButton(props) {
|
|
2125
2198
|
var _props$iconType = props.iconType,
|
|
2126
|
-
iconType = _props$iconType === void 0 ?
|
|
2199
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
2127
2200
|
icon = props.icon,
|
|
2128
2201
|
className = props.className,
|
|
2129
2202
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
2130
|
-
return
|
|
2131
|
-
type:
|
|
2203
|
+
return jsxRuntime.jsx("button", _extends({
|
|
2204
|
+
type: 'button',
|
|
2132
2205
|
className: "btn btn-" + iconType + " " + className
|
|
2133
|
-
}, otherProps
|
|
2134
|
-
|
|
2206
|
+
}, otherProps, {
|
|
2207
|
+
children: jsxRuntime.jsx("i", {
|
|
2208
|
+
className: "glyphicon glyphicon-" + icon
|
|
2209
|
+
})
|
|
2210
|
+
}));
|
|
2211
|
+
}
|
|
2212
|
+
function CopyButton(props) {
|
|
2213
|
+
var translateString = props.registry.translateString;
|
|
2214
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2215
|
+
title: translateString(utils.TranslatableString.CopyButton),
|
|
2216
|
+
className: 'array-item-copy'
|
|
2217
|
+
}, props, {
|
|
2218
|
+
icon: 'copy'
|
|
2135
2219
|
}));
|
|
2136
2220
|
}
|
|
2137
2221
|
function MoveDownButton(props) {
|
|
2138
2222
|
var translateString = props.registry.translateString;
|
|
2139
|
-
return
|
|
2223
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2140
2224
|
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
2141
|
-
className:
|
|
2225
|
+
className: 'array-item-move-down'
|
|
2142
2226
|
}, props, {
|
|
2143
|
-
icon:
|
|
2227
|
+
icon: 'arrow-down'
|
|
2144
2228
|
}));
|
|
2145
2229
|
}
|
|
2146
2230
|
function MoveUpButton(props) {
|
|
2147
2231
|
var translateString = props.registry.translateString;
|
|
2148
|
-
return
|
|
2232
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2149
2233
|
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
2150
|
-
className:
|
|
2234
|
+
className: 'array-item-move-up'
|
|
2151
2235
|
}, props, {
|
|
2152
|
-
icon:
|
|
2236
|
+
icon: 'arrow-up'
|
|
2153
2237
|
}));
|
|
2154
2238
|
}
|
|
2155
2239
|
function RemoveButton(props) {
|
|
2156
2240
|
var translateString = props.registry.translateString;
|
|
2157
|
-
return
|
|
2241
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2158
2242
|
title: translateString(utils.TranslatableString.RemoveButton),
|
|
2159
|
-
className:
|
|
2243
|
+
className: 'array-item-remove'
|
|
2160
2244
|
}, props, {
|
|
2161
|
-
iconType:
|
|
2162
|
-
icon:
|
|
2245
|
+
iconType: 'danger',
|
|
2246
|
+
icon: 'remove'
|
|
2163
2247
|
}));
|
|
2164
2248
|
}
|
|
2165
2249
|
|
|
@@ -2171,25 +2255,28 @@ function AddButton(_ref) {
|
|
|
2171
2255
|
disabled = _ref.disabled,
|
|
2172
2256
|
registry = _ref.registry;
|
|
2173
2257
|
var translateString = registry.translateString;
|
|
2174
|
-
return
|
|
2175
|
-
className:
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2258
|
+
return jsxRuntime.jsx("div", {
|
|
2259
|
+
className: 'row',
|
|
2260
|
+
children: jsxRuntime.jsx("p", {
|
|
2261
|
+
className: "col-xs-3 col-xs-offset-9 text-right " + className,
|
|
2262
|
+
children: jsxRuntime.jsx(IconButton, {
|
|
2263
|
+
iconType: 'info',
|
|
2264
|
+
icon: 'plus',
|
|
2265
|
+
className: 'btn-add col-xs-12',
|
|
2266
|
+
title: translateString(utils.TranslatableString.AddButton),
|
|
2267
|
+
onClick: onClick,
|
|
2268
|
+
disabled: disabled,
|
|
2269
|
+
registry: registry
|
|
2270
|
+
})
|
|
2271
|
+
})
|
|
2272
|
+
});
|
|
2187
2273
|
}
|
|
2188
2274
|
|
|
2189
2275
|
function buttonTemplates() {
|
|
2190
2276
|
return {
|
|
2191
2277
|
SubmitButton: SubmitButton,
|
|
2192
2278
|
AddButton: AddButton,
|
|
2279
|
+
CopyButton: CopyButton,
|
|
2193
2280
|
MoveDownButton: MoveDownButton,
|
|
2194
2281
|
MoveUpButton: MoveUpButton,
|
|
2195
2282
|
RemoveButton: RemoveButton
|
|
@@ -2206,16 +2293,18 @@ function DescriptionField(props) {
|
|
|
2206
2293
|
if (!description) {
|
|
2207
2294
|
return null;
|
|
2208
2295
|
}
|
|
2209
|
-
if (typeof description ===
|
|
2210
|
-
return
|
|
2296
|
+
if (typeof description === 'string') {
|
|
2297
|
+
return jsxRuntime.jsx("p", {
|
|
2211
2298
|
id: id,
|
|
2212
|
-
className:
|
|
2213
|
-
|
|
2299
|
+
className: 'field-description',
|
|
2300
|
+
children: description
|
|
2301
|
+
});
|
|
2214
2302
|
} else {
|
|
2215
|
-
return
|
|
2303
|
+
return jsxRuntime.jsx("div", {
|
|
2216
2304
|
id: id,
|
|
2217
|
-
className:
|
|
2218
|
-
|
|
2305
|
+
className: 'field-description',
|
|
2306
|
+
children: description
|
|
2307
|
+
});
|
|
2219
2308
|
}
|
|
2220
2309
|
}
|
|
2221
2310
|
|
|
@@ -2227,23 +2316,27 @@ function ErrorList(_ref) {
|
|
|
2227
2316
|
var errors = _ref.errors,
|
|
2228
2317
|
registry = _ref.registry;
|
|
2229
2318
|
var translateString = registry.translateString;
|
|
2230
|
-
return
|
|
2231
|
-
className:
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2319
|
+
return jsxRuntime.jsxs("div", {
|
|
2320
|
+
className: 'panel panel-danger errors',
|
|
2321
|
+
children: [jsxRuntime.jsx("div", {
|
|
2322
|
+
className: 'panel-heading',
|
|
2323
|
+
children: jsxRuntime.jsx("h3", {
|
|
2324
|
+
className: 'panel-title',
|
|
2325
|
+
children: translateString(utils.TranslatableString.ErrorsLabel)
|
|
2326
|
+
})
|
|
2327
|
+
}), jsxRuntime.jsx("ul", {
|
|
2328
|
+
className: 'list-group',
|
|
2329
|
+
children: errors.map(function (error, i) {
|
|
2330
|
+
return jsxRuntime.jsx("li", {
|
|
2331
|
+
className: 'list-group-item text-danger',
|
|
2332
|
+
children: error.stack
|
|
2333
|
+
}, i);
|
|
2334
|
+
})
|
|
2335
|
+
})]
|
|
2336
|
+
});
|
|
2244
2337
|
}
|
|
2245
2338
|
|
|
2246
|
-
var REQUIRED_FIELD_SYMBOL$1 =
|
|
2339
|
+
var REQUIRED_FIELD_SYMBOL$1 = '*';
|
|
2247
2340
|
/** Renders a label for a field
|
|
2248
2341
|
*
|
|
2249
2342
|
* @param props - The `LabelProps` for this component
|
|
@@ -2255,12 +2348,14 @@ function Label(props) {
|
|
|
2255
2348
|
if (!label) {
|
|
2256
2349
|
return null;
|
|
2257
2350
|
}
|
|
2258
|
-
return
|
|
2259
|
-
className:
|
|
2260
|
-
htmlFor: id
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2351
|
+
return jsxRuntime.jsxs("label", {
|
|
2352
|
+
className: 'control-label',
|
|
2353
|
+
htmlFor: id,
|
|
2354
|
+
children: [label, required && jsxRuntime.jsx("span", {
|
|
2355
|
+
className: 'required',
|
|
2356
|
+
children: REQUIRED_FIELD_SYMBOL$1
|
|
2357
|
+
})]
|
|
2358
|
+
});
|
|
2264
2359
|
}
|
|
2265
2360
|
|
|
2266
2361
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -2281,17 +2376,20 @@ function FieldTemplate(props) {
|
|
|
2281
2376
|
registry = props.registry,
|
|
2282
2377
|
uiSchema = props.uiSchema;
|
|
2283
2378
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
2284
|
-
var WrapIfAdditionalTemplate = utils.getTemplate(
|
|
2379
|
+
var WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
2285
2380
|
if (hidden) {
|
|
2286
|
-
return
|
|
2287
|
-
className:
|
|
2288
|
-
|
|
2381
|
+
return jsxRuntime.jsx("div", {
|
|
2382
|
+
className: 'hidden',
|
|
2383
|
+
children: children
|
|
2384
|
+
});
|
|
2289
2385
|
}
|
|
2290
|
-
return
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2386
|
+
return jsxRuntime.jsxs(WrapIfAdditionalTemplate, _extends({}, props, {
|
|
2387
|
+
children: [displayLabel && jsxRuntime.jsx(Label, {
|
|
2388
|
+
label: label,
|
|
2389
|
+
required: required,
|
|
2390
|
+
id: id
|
|
2391
|
+
}), displayLabel && description ? description : null, children, errors, help]
|
|
2392
|
+
}));
|
|
2295
2393
|
}
|
|
2296
2394
|
|
|
2297
2395
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -2306,17 +2404,20 @@ function FieldErrorTemplate(props) {
|
|
|
2306
2404
|
return null;
|
|
2307
2405
|
}
|
|
2308
2406
|
var id = utils.errorId(idSchema);
|
|
2309
|
-
return
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2407
|
+
return jsxRuntime.jsx("div", {
|
|
2408
|
+
children: jsxRuntime.jsx("ul", {
|
|
2409
|
+
id: id,
|
|
2410
|
+
className: 'error-detail bs-callout bs-callout-info',
|
|
2411
|
+
children: errors.filter(function (elem) {
|
|
2412
|
+
return !!elem;
|
|
2413
|
+
}).map(function (error, index) {
|
|
2414
|
+
return jsxRuntime.jsx("li", {
|
|
2415
|
+
className: 'text-danger',
|
|
2416
|
+
children: error
|
|
2417
|
+
}, index);
|
|
2418
|
+
})
|
|
2419
|
+
})
|
|
2420
|
+
});
|
|
2320
2421
|
}
|
|
2321
2422
|
|
|
2322
2423
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -2330,16 +2431,18 @@ function FieldHelpTemplate(props) {
|
|
|
2330
2431
|
return null;
|
|
2331
2432
|
}
|
|
2332
2433
|
var id = utils.helpId(idSchema);
|
|
2333
|
-
if (typeof help ===
|
|
2334
|
-
return
|
|
2434
|
+
if (typeof help === 'string') {
|
|
2435
|
+
return jsxRuntime.jsx("p", {
|
|
2335
2436
|
id: id,
|
|
2336
|
-
className:
|
|
2337
|
-
|
|
2437
|
+
className: 'help-block',
|
|
2438
|
+
children: help
|
|
2439
|
+
});
|
|
2338
2440
|
}
|
|
2339
|
-
return
|
|
2441
|
+
return jsxRuntime.jsx("div", {
|
|
2340
2442
|
id: id,
|
|
2341
|
-
className:
|
|
2342
|
-
|
|
2443
|
+
className: 'help-block',
|
|
2444
|
+
children: help
|
|
2445
|
+
});
|
|
2343
2446
|
}
|
|
2344
2447
|
|
|
2345
2448
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -2362,37 +2465,38 @@ function ObjectFieldTemplate(props) {
|
|
|
2362
2465
|
title = props.title,
|
|
2363
2466
|
uiSchema = props.uiSchema;
|
|
2364
2467
|
var options = utils.getUiOptions(uiSchema);
|
|
2365
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
2366
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
2468
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
2469
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2367
2470
|
// Button templates are not overridden in the uiSchema
|
|
2368
2471
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2369
|
-
return
|
|
2370
|
-
id: idSchema.$id
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2472
|
+
return jsxRuntime.jsxs("fieldset", {
|
|
2473
|
+
id: idSchema.$id,
|
|
2474
|
+
children: [(options.title || title) && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2475
|
+
id: utils.titleId(idSchema),
|
|
2476
|
+
title: options.title || title,
|
|
2477
|
+
required: required,
|
|
2478
|
+
schema: schema,
|
|
2479
|
+
uiSchema: uiSchema,
|
|
2480
|
+
registry: registry
|
|
2481
|
+
}), (options.description || description) && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2482
|
+
id: utils.descriptionId(idSchema),
|
|
2483
|
+
description: options.description || description,
|
|
2484
|
+
schema: schema,
|
|
2485
|
+
uiSchema: uiSchema,
|
|
2486
|
+
registry: registry
|
|
2487
|
+
}), properties.map(function (prop) {
|
|
2488
|
+
return prop.content;
|
|
2489
|
+
}), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(AddButton, {
|
|
2490
|
+
className: 'object-property-expand',
|
|
2491
|
+
onClick: onAddClick(schema),
|
|
2492
|
+
disabled: disabled || readonly,
|
|
2493
|
+
uiSchema: uiSchema,
|
|
2494
|
+
registry: registry
|
|
2495
|
+
})]
|
|
2496
|
+
});
|
|
2393
2497
|
}
|
|
2394
2498
|
|
|
2395
|
-
var REQUIRED_FIELD_SYMBOL =
|
|
2499
|
+
var REQUIRED_FIELD_SYMBOL = '*';
|
|
2396
2500
|
/** The `TitleField` is the template to use to render the title of a field
|
|
2397
2501
|
*
|
|
2398
2502
|
* @param props - The `TitleFieldProps` for this component
|
|
@@ -2401,11 +2505,13 @@ function TitleField(props) {
|
|
|
2401
2505
|
var id = props.id,
|
|
2402
2506
|
title = props.title,
|
|
2403
2507
|
required = props.required;
|
|
2404
|
-
return
|
|
2405
|
-
id: id
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2508
|
+
return jsxRuntime.jsxs("legend", {
|
|
2509
|
+
id: id,
|
|
2510
|
+
children: [title, required && jsxRuntime.jsx("span", {
|
|
2511
|
+
className: 'required',
|
|
2512
|
+
children: REQUIRED_FIELD_SYMBOL
|
|
2513
|
+
})]
|
|
2514
|
+
});
|
|
2409
2515
|
}
|
|
2410
2516
|
|
|
2411
2517
|
/** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
|
|
@@ -2429,9 +2535,16 @@ function UnsupportedField(props) {
|
|
|
2429
2535
|
translateEnum = translateEnum === utils.TranslatableString.UnsupportedField ? utils.TranslatableString.UnsupportedFieldWithReason : utils.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2430
2536
|
translateParams.push(reason);
|
|
2431
2537
|
}
|
|
2432
|
-
return
|
|
2433
|
-
className:
|
|
2434
|
-
|
|
2538
|
+
return jsxRuntime.jsxs("div", {
|
|
2539
|
+
className: 'unsupported-field',
|
|
2540
|
+
children: [jsxRuntime.jsx("p", {
|
|
2541
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
2542
|
+
children: translateString(translateEnum, translateParams)
|
|
2543
|
+
})
|
|
2544
|
+
}), schema && jsxRuntime.jsx("pre", {
|
|
2545
|
+
children: JSON.stringify(schema, null, 2)
|
|
2546
|
+
})]
|
|
2547
|
+
});
|
|
2435
2548
|
}
|
|
2436
2549
|
|
|
2437
2550
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -2460,46 +2573,53 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2460
2573
|
var keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
2461
2574
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2462
2575
|
if (!additional) {
|
|
2463
|
-
return
|
|
2576
|
+
return jsxRuntime.jsx("div", {
|
|
2464
2577
|
className: classNames,
|
|
2465
|
-
style: style
|
|
2466
|
-
|
|
2578
|
+
style: style,
|
|
2579
|
+
children: children
|
|
2580
|
+
});
|
|
2467
2581
|
}
|
|
2468
|
-
return
|
|
2582
|
+
return jsxRuntime.jsx("div", {
|
|
2469
2583
|
className: classNames,
|
|
2470
|
-
style: style
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2584
|
+
style: style,
|
|
2585
|
+
children: jsxRuntime.jsxs("div", {
|
|
2586
|
+
className: 'row',
|
|
2587
|
+
children: [jsxRuntime.jsx("div", {
|
|
2588
|
+
className: 'col-xs-5 form-additional',
|
|
2589
|
+
children: jsxRuntime.jsxs("div", {
|
|
2590
|
+
className: 'form-group',
|
|
2591
|
+
children: [jsxRuntime.jsx(Label, {
|
|
2592
|
+
label: keyLabel,
|
|
2593
|
+
required: required,
|
|
2594
|
+
id: id + "-key"
|
|
2595
|
+
}), jsxRuntime.jsx("input", {
|
|
2596
|
+
className: 'form-control',
|
|
2597
|
+
type: 'text',
|
|
2598
|
+
id: id + "-key",
|
|
2599
|
+
onBlur: function onBlur(event) {
|
|
2600
|
+
return onKeyChange(event.target.value);
|
|
2601
|
+
},
|
|
2602
|
+
defaultValue: label
|
|
2603
|
+
})]
|
|
2604
|
+
})
|
|
2605
|
+
}), jsxRuntime.jsx("div", {
|
|
2606
|
+
className: 'form-additional form-group col-xs-5',
|
|
2607
|
+
children: children
|
|
2608
|
+
}), jsxRuntime.jsx("div", {
|
|
2609
|
+
className: 'col-xs-2',
|
|
2610
|
+
children: jsxRuntime.jsx(RemoveButton, {
|
|
2611
|
+
className: 'array-item-remove btn-block',
|
|
2612
|
+
style: {
|
|
2613
|
+
border: '0'
|
|
2614
|
+
},
|
|
2615
|
+
disabled: disabled || readonly,
|
|
2616
|
+
onClick: onDropPropertyClick(label),
|
|
2617
|
+
uiSchema: uiSchema,
|
|
2618
|
+
registry: registry
|
|
2619
|
+
})
|
|
2620
|
+
})]
|
|
2621
|
+
})
|
|
2622
|
+
});
|
|
2503
2623
|
}
|
|
2504
2624
|
|
|
2505
2625
|
function templates() {
|
|
@@ -2548,29 +2668,29 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
2548
2668
|
minute = state.minute,
|
|
2549
2669
|
second = state.second;
|
|
2550
2670
|
var data = [{
|
|
2551
|
-
type:
|
|
2671
|
+
type: 'year',
|
|
2552
2672
|
range: yearsRange,
|
|
2553
2673
|
value: year
|
|
2554
2674
|
}, {
|
|
2555
|
-
type:
|
|
2675
|
+
type: 'month',
|
|
2556
2676
|
range: [1, 12],
|
|
2557
2677
|
value: month
|
|
2558
2678
|
}, {
|
|
2559
|
-
type:
|
|
2679
|
+
type: 'day',
|
|
2560
2680
|
range: [1, 31],
|
|
2561
2681
|
value: day
|
|
2562
2682
|
}];
|
|
2563
2683
|
if (time) {
|
|
2564
2684
|
data.push({
|
|
2565
|
-
type:
|
|
2685
|
+
type: 'hour',
|
|
2566
2686
|
range: [0, 23],
|
|
2567
2687
|
value: hour
|
|
2568
2688
|
}, {
|
|
2569
|
-
type:
|
|
2689
|
+
type: 'minute',
|
|
2570
2690
|
range: [0, 59],
|
|
2571
2691
|
value: minute
|
|
2572
2692
|
}, {
|
|
2573
|
-
type:
|
|
2693
|
+
type: 'second',
|
|
2574
2694
|
range: [0, 59],
|
|
2575
2695
|
value: second
|
|
2576
2696
|
});
|
|
@@ -2583,20 +2703,22 @@ function DateElement(_ref) {
|
|
|
2583
2703
|
value = _ref.value,
|
|
2584
2704
|
select = _ref.select,
|
|
2585
2705
|
rootId = _ref.rootId,
|
|
2706
|
+
name = _ref.name,
|
|
2586
2707
|
disabled = _ref.disabled,
|
|
2587
2708
|
readonly = _ref.readonly,
|
|
2588
2709
|
autofocus = _ref.autofocus,
|
|
2589
2710
|
registry = _ref.registry,
|
|
2590
2711
|
onBlur = _ref.onBlur,
|
|
2591
2712
|
onFocus = _ref.onFocus;
|
|
2592
|
-
var id = rootId +
|
|
2713
|
+
var id = rootId + '_' + type;
|
|
2593
2714
|
var SelectWidget = registry.widgets.SelectWidget;
|
|
2594
|
-
return
|
|
2715
|
+
return jsxRuntime.jsx(SelectWidget, {
|
|
2595
2716
|
schema: {
|
|
2596
|
-
type:
|
|
2717
|
+
type: 'integer'
|
|
2597
2718
|
},
|
|
2598
2719
|
id: id,
|
|
2599
|
-
|
|
2720
|
+
name: name,
|
|
2721
|
+
className: 'form-control',
|
|
2600
2722
|
options: {
|
|
2601
2723
|
enumOptions: rangeOptions(range[0], range[1])
|
|
2602
2724
|
},
|
|
@@ -2611,7 +2733,7 @@ function DateElement(_ref) {
|
|
|
2611
2733
|
onBlur: onBlur,
|
|
2612
2734
|
onFocus: onFocus,
|
|
2613
2735
|
registry: registry,
|
|
2614
|
-
label:
|
|
2736
|
+
label: '',
|
|
2615
2737
|
"aria-describedby": utils.ariaDescribedByIds(rootId)
|
|
2616
2738
|
});
|
|
2617
2739
|
}
|
|
@@ -2629,33 +2751,34 @@ function AltDateWidget(_ref2) {
|
|
|
2629
2751
|
autofocus = _ref2$autofocus === void 0 ? false : _ref2$autofocus,
|
|
2630
2752
|
options = _ref2.options,
|
|
2631
2753
|
id = _ref2.id,
|
|
2754
|
+
name = _ref2.name,
|
|
2632
2755
|
registry = _ref2.registry,
|
|
2633
2756
|
onBlur = _ref2.onBlur,
|
|
2634
2757
|
onFocus = _ref2.onFocus,
|
|
2635
2758
|
onChange = _ref2.onChange,
|
|
2636
2759
|
value = _ref2.value;
|
|
2637
2760
|
var translateString = registry.translateString;
|
|
2638
|
-
var _useReducer =
|
|
2761
|
+
var _useReducer = react.useReducer(function (state, action) {
|
|
2639
2762
|
return _extends({}, state, action);
|
|
2640
2763
|
}, utils.parseDateString(value, time)),
|
|
2641
2764
|
state = _useReducer[0],
|
|
2642
2765
|
setState = _useReducer[1];
|
|
2643
|
-
|
|
2766
|
+
react.useEffect(function () {
|
|
2644
2767
|
if (value && value !== utils.toDateString(state, time)) {
|
|
2645
2768
|
setState(utils.parseDateString(value, time));
|
|
2646
2769
|
}
|
|
2647
2770
|
}, [value, state, time]);
|
|
2648
|
-
|
|
2771
|
+
react.useEffect(function () {
|
|
2649
2772
|
if (readyForChange(state)) {
|
|
2650
2773
|
// Only propagate to parent state if we have a complete date{time}
|
|
2651
2774
|
onChange(utils.toDateString(state, time));
|
|
2652
2775
|
}
|
|
2653
2776
|
}, [state, time, onChange]);
|
|
2654
|
-
var handleChange =
|
|
2777
|
+
var handleChange = react.useCallback(function (property, value) {
|
|
2655
2778
|
var _setState;
|
|
2656
2779
|
setState((_setState = {}, _setState[property] = value, _setState));
|
|
2657
2780
|
}, []);
|
|
2658
|
-
var handleSetNow =
|
|
2781
|
+
var handleSetNow = react.useCallback(function (event) {
|
|
2659
2782
|
event.preventDefault();
|
|
2660
2783
|
if (disabled || readonly) {
|
|
2661
2784
|
return;
|
|
@@ -2663,44 +2786,50 @@ function AltDateWidget(_ref2) {
|
|
|
2663
2786
|
var nowDateObj = utils.parseDateString(new Date().toJSON(), time);
|
|
2664
2787
|
setState(nowDateObj);
|
|
2665
2788
|
}, [disabled, readonly, time]);
|
|
2666
|
-
var handleClear =
|
|
2789
|
+
var handleClear = react.useCallback(function (event) {
|
|
2667
2790
|
event.preventDefault();
|
|
2668
2791
|
if (disabled || readonly) {
|
|
2669
2792
|
return;
|
|
2670
2793
|
}
|
|
2671
|
-
setState(utils.parseDateString(
|
|
2794
|
+
setState(utils.parseDateString('', time));
|
|
2672
2795
|
onChange(undefined);
|
|
2673
2796
|
}, [disabled, readonly, time, onChange]);
|
|
2674
|
-
return
|
|
2675
|
-
className:
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2797
|
+
return jsxRuntime.jsxs("ul", {
|
|
2798
|
+
className: 'list-inline',
|
|
2799
|
+
children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2800
|
+
return jsxRuntime.jsx("li", {
|
|
2801
|
+
className: 'list-inline-item',
|
|
2802
|
+
children: jsxRuntime.jsx(DateElement, _extends({
|
|
2803
|
+
rootId: id,
|
|
2804
|
+
name: name,
|
|
2805
|
+
select: handleChange
|
|
2806
|
+
}, elemProps, {
|
|
2807
|
+
disabled: disabled,
|
|
2808
|
+
readonly: readonly,
|
|
2809
|
+
registry: registry,
|
|
2810
|
+
onBlur: onBlur,
|
|
2811
|
+
onFocus: onFocus,
|
|
2812
|
+
autofocus: autofocus && i === 0
|
|
2813
|
+
}))
|
|
2814
|
+
}, i);
|
|
2815
|
+
}), (options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && jsxRuntime.jsx("li", {
|
|
2816
|
+
className: 'list-inline-item',
|
|
2817
|
+
children: jsxRuntime.jsx("a", {
|
|
2818
|
+
href: '#',
|
|
2819
|
+
className: 'btn btn-info btn-now',
|
|
2820
|
+
onClick: handleSetNow,
|
|
2821
|
+
children: translateString(utils.TranslatableString.NowLabel)
|
|
2822
|
+
})
|
|
2823
|
+
}), (options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && jsxRuntime.jsx("li", {
|
|
2824
|
+
className: 'list-inline-item',
|
|
2825
|
+
children: jsxRuntime.jsx("a", {
|
|
2826
|
+
href: '#',
|
|
2827
|
+
className: 'btn btn-warning btn-clear',
|
|
2828
|
+
onClick: handleClear,
|
|
2829
|
+
children: translateString(utils.TranslatableString.ClearLabel)
|
|
2830
|
+
})
|
|
2831
|
+
})]
|
|
2832
|
+
});
|
|
2704
2833
|
}
|
|
2705
2834
|
|
|
2706
2835
|
var _excluded$1 = ["time"];
|
|
@@ -2714,7 +2843,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2714
2843
|
time = _ref$time === void 0 ? true : _ref$time,
|
|
2715
2844
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2716
2845
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
2717
|
-
return
|
|
2846
|
+
return jsxRuntime.jsx(AltDateWidget, _extends({
|
|
2718
2847
|
time: time
|
|
2719
2848
|
}, props));
|
|
2720
2849
|
}
|
|
@@ -2739,41 +2868,46 @@ function CheckboxWidget(_ref) {
|
|
|
2739
2868
|
onFocus = _ref.onFocus,
|
|
2740
2869
|
onChange = _ref.onChange,
|
|
2741
2870
|
registry = _ref.registry;
|
|
2742
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
2871
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
2743
2872
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
2744
2873
|
// the "required" attribute if the field value must be "true", due to the
|
|
2745
2874
|
// "const" or "enum" keywords
|
|
2746
2875
|
var required = utils.schemaRequiresTrueValue(schema);
|
|
2747
|
-
var handleChange =
|
|
2876
|
+
var handleChange = react.useCallback(function (event) {
|
|
2748
2877
|
return onChange(event.target.checked);
|
|
2749
2878
|
}, [onChange]);
|
|
2750
|
-
var handleBlur =
|
|
2879
|
+
var handleBlur = react.useCallback(function (event) {
|
|
2751
2880
|
return onBlur(id, event.target.checked);
|
|
2752
2881
|
}, [onBlur, id]);
|
|
2753
|
-
var handleFocus =
|
|
2882
|
+
var handleFocus = react.useCallback(function (event) {
|
|
2754
2883
|
return onFocus(id, event.target.checked);
|
|
2755
2884
|
}, [onFocus, id]);
|
|
2756
|
-
return
|
|
2757
|
-
className: "checkbox " + (disabled || readonly ?
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2885
|
+
return jsxRuntime.jsxs("div", {
|
|
2886
|
+
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2887
|
+
children: [schema.description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2888
|
+
id: utils.descriptionId(id),
|
|
2889
|
+
description: schema.description,
|
|
2890
|
+
schema: schema,
|
|
2891
|
+
uiSchema: uiSchema,
|
|
2892
|
+
registry: registry
|
|
2893
|
+
}), jsxRuntime.jsxs("label", {
|
|
2894
|
+
children: [jsxRuntime.jsx("input", {
|
|
2895
|
+
type: 'checkbox',
|
|
2896
|
+
id: id,
|
|
2897
|
+
name: id,
|
|
2898
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
2899
|
+
required: required,
|
|
2900
|
+
disabled: disabled || readonly,
|
|
2901
|
+
autoFocus: autofocus,
|
|
2902
|
+
onChange: handleChange,
|
|
2903
|
+
onBlur: handleBlur,
|
|
2904
|
+
onFocus: handleFocus,
|
|
2905
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2906
|
+
}), jsxRuntime.jsx("span", {
|
|
2907
|
+
children: label
|
|
2908
|
+
})]
|
|
2909
|
+
})]
|
|
2910
|
+
});
|
|
2777
2911
|
}
|
|
2778
2912
|
|
|
2779
2913
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
@@ -2798,49 +2932,56 @@ function CheckboxesWidget(_ref) {
|
|
|
2798
2932
|
onBlur = _ref.onBlur,
|
|
2799
2933
|
onFocus = _ref.onFocus;
|
|
2800
2934
|
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2801
|
-
var handleBlur =
|
|
2935
|
+
var handleBlur = react.useCallback(function (_ref2) {
|
|
2802
2936
|
var value = _ref2.target.value;
|
|
2803
2937
|
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2804
2938
|
}, [onBlur, id]);
|
|
2805
|
-
var handleFocus =
|
|
2939
|
+
var handleFocus = react.useCallback(function (_ref3) {
|
|
2806
2940
|
var value = _ref3.target.value;
|
|
2807
2941
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
2808
2942
|
}, [onFocus, id]);
|
|
2809
|
-
return
|
|
2810
|
-
className:
|
|
2811
|
-
id: id
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2943
|
+
return jsxRuntime.jsx("div", {
|
|
2944
|
+
className: 'checkboxes',
|
|
2945
|
+
id: id,
|
|
2946
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
2947
|
+
var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
2948
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2949
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
2950
|
+
var handleChange = function handleChange(event) {
|
|
2951
|
+
if (event.target.checked) {
|
|
2952
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
2953
|
+
} else {
|
|
2954
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
2955
|
+
}
|
|
2956
|
+
};
|
|
2957
|
+
var checkbox = jsxRuntime.jsxs("span", {
|
|
2958
|
+
children: [jsxRuntime.jsx("input", {
|
|
2959
|
+
type: 'checkbox',
|
|
2960
|
+
id: utils.optionId(id, index),
|
|
2961
|
+
name: id,
|
|
2962
|
+
checked: checked,
|
|
2963
|
+
value: String(index),
|
|
2964
|
+
disabled: disabled || itemDisabled || readonly,
|
|
2965
|
+
autoFocus: autofocus && index === 0,
|
|
2966
|
+
onChange: handleChange,
|
|
2967
|
+
onBlur: handleBlur,
|
|
2968
|
+
onFocus: handleFocus,
|
|
2969
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2970
|
+
}), jsxRuntime.jsx("span", {
|
|
2971
|
+
children: option.label
|
|
2972
|
+
})]
|
|
2973
|
+
});
|
|
2974
|
+
return inline ? jsxRuntime.jsx("label", {
|
|
2975
|
+
className: "checkbox-inline " + disabledCls,
|
|
2976
|
+
children: checkbox
|
|
2977
|
+
}, index) : jsxRuntime.jsx("div", {
|
|
2978
|
+
className: "checkbox " + disabledCls,
|
|
2979
|
+
children: jsxRuntime.jsx("label", {
|
|
2980
|
+
children: checkbox
|
|
2981
|
+
})
|
|
2982
|
+
}, index);
|
|
2983
|
+
})
|
|
2984
|
+
});
|
|
2844
2985
|
}
|
|
2845
2986
|
|
|
2846
2987
|
/** The `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
|
|
@@ -2853,9 +2994,9 @@ function ColorWidget(props) {
|
|
|
2853
2994
|
readonly = props.readonly,
|
|
2854
2995
|
options = props.options,
|
|
2855
2996
|
registry = props.registry;
|
|
2856
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2857
|
-
return
|
|
2858
|
-
type:
|
|
2997
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
2998
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
2999
|
+
type: 'color'
|
|
2859
3000
|
}, props, {
|
|
2860
3001
|
disabled: disabled || readonly
|
|
2861
3002
|
}));
|
|
@@ -2870,12 +3011,12 @@ function DateWidget(props) {
|
|
|
2870
3011
|
var onChange = props.onChange,
|
|
2871
3012
|
options = props.options,
|
|
2872
3013
|
registry = props.registry;
|
|
2873
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2874
|
-
var handleChange =
|
|
3014
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3015
|
+
var handleChange = react.useCallback(function (value) {
|
|
2875
3016
|
return onChange(value || undefined);
|
|
2876
3017
|
}, [onChange]);
|
|
2877
|
-
return
|
|
2878
|
-
type:
|
|
3018
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3019
|
+
type: 'date'
|
|
2879
3020
|
}, props, {
|
|
2880
3021
|
onChange: handleChange
|
|
2881
3022
|
}));
|
|
@@ -2891,9 +3032,9 @@ function DateTimeWidget(props) {
|
|
|
2891
3032
|
value = props.value,
|
|
2892
3033
|
options = props.options,
|
|
2893
3034
|
registry = props.registry;
|
|
2894
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2895
|
-
return
|
|
2896
|
-
type:
|
|
3035
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3036
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3037
|
+
type: 'datetime-local'
|
|
2897
3038
|
}, props, {
|
|
2898
3039
|
value: utils.utcToLocal(value),
|
|
2899
3040
|
onChange: function onChange(value) {
|
|
@@ -2909,9 +3050,9 @@ function DateTimeWidget(props) {
|
|
|
2909
3050
|
function EmailWidget(props) {
|
|
2910
3051
|
var options = props.options,
|
|
2911
3052
|
registry = props.registry;
|
|
2912
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
2913
|
-
return
|
|
2914
|
-
type:
|
|
3053
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3054
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3055
|
+
type: 'email'
|
|
2915
3056
|
}, props));
|
|
2916
3057
|
}
|
|
2917
3058
|
|
|
@@ -2919,7 +3060,7 @@ function addNameToDataURL(dataURL, name) {
|
|
|
2919
3060
|
if (dataURL === null) {
|
|
2920
3061
|
return null;
|
|
2921
3062
|
}
|
|
2922
|
-
return dataURL.replace(
|
|
3063
|
+
return dataURL.replace(';base64', ";name=" + encodeURIComponent(name) + ";base64");
|
|
2923
3064
|
}
|
|
2924
3065
|
function processFile(file) {
|
|
2925
3066
|
var name = file.name,
|
|
@@ -2930,7 +3071,7 @@ function processFile(file) {
|
|
|
2930
3071
|
reader.onerror = reject;
|
|
2931
3072
|
reader.onload = function (event) {
|
|
2932
3073
|
var _event$target;
|
|
2933
|
-
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) ===
|
|
3074
|
+
if (typeof ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result) === 'string') {
|
|
2934
3075
|
resolve({
|
|
2935
3076
|
dataURL: addNameToDataURL(event.target.result, name),
|
|
2936
3077
|
name: name,
|
|
@@ -2959,20 +3100,23 @@ function FilesInfo(_ref) {
|
|
|
2959
3100
|
return null;
|
|
2960
3101
|
}
|
|
2961
3102
|
var translateString = registry.translateString;
|
|
2962
|
-
return
|
|
2963
|
-
className:
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3103
|
+
return jsxRuntime.jsx("ul", {
|
|
3104
|
+
className: 'file-info',
|
|
3105
|
+
children: filesInfo.map(function (fileInfo, key) {
|
|
3106
|
+
var name = fileInfo.name,
|
|
3107
|
+
size = fileInfo.size,
|
|
3108
|
+
type = fileInfo.type;
|
|
3109
|
+
return jsxRuntime.jsx("li", {
|
|
3110
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3111
|
+
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3112
|
+
})
|
|
3113
|
+
}, key);
|
|
3114
|
+
})
|
|
3115
|
+
});
|
|
2972
3116
|
}
|
|
2973
3117
|
function extractFileInfo(dataURLs) {
|
|
2974
3118
|
return dataURLs.filter(function (dataURL) {
|
|
2975
|
-
return
|
|
3119
|
+
return dataURL;
|
|
2976
3120
|
}).map(function (dataURL) {
|
|
2977
3121
|
var _dataURItoBlob = utils.dataURItoBlob(dataURL),
|
|
2978
3122
|
blob = _dataURItoBlob.blob,
|
|
@@ -2988,24 +3132,22 @@ function extractFileInfo(dataURLs) {
|
|
|
2988
3132
|
* The `FileWidget` is a widget for rendering file upload fields.
|
|
2989
3133
|
* It is typically used with a string property with data-url format.
|
|
2990
3134
|
*/
|
|
2991
|
-
function FileWidget(
|
|
2992
|
-
var
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
registry = _ref2.registry;
|
|
3002
|
-
var extractedFilesInfo = React.useMemo(function () {
|
|
3135
|
+
function FileWidget(props) {
|
|
3136
|
+
var disabled = props.disabled,
|
|
3137
|
+
readonly = props.readonly,
|
|
3138
|
+
multiple = props.multiple,
|
|
3139
|
+
onChange = props.onChange,
|
|
3140
|
+
value = props.value,
|
|
3141
|
+
options = props.options,
|
|
3142
|
+
registry = props.registry;
|
|
3143
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3144
|
+
var extractedFilesInfo = react.useMemo(function () {
|
|
3003
3145
|
return Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value]);
|
|
3004
3146
|
}, [value]);
|
|
3005
|
-
var _useState =
|
|
3147
|
+
var _useState = react.useState(extractedFilesInfo),
|
|
3006
3148
|
filesInfo = _useState[0],
|
|
3007
3149
|
setFilesInfo = _useState[1];
|
|
3008
|
-
var handleChange =
|
|
3150
|
+
var handleChange = react.useCallback(function (event) {
|
|
3009
3151
|
if (!event.target.files) {
|
|
3010
3152
|
return;
|
|
3011
3153
|
}
|
|
@@ -3021,21 +3163,18 @@ function FileWidget(_ref2) {
|
|
|
3021
3163
|
}
|
|
3022
3164
|
});
|
|
3023
3165
|
}, [multiple, onChange]);
|
|
3024
|
-
return
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
})
|
|
3036
|
-
filesInfo: filesInfo,
|
|
3037
|
-
registry: registry
|
|
3038
|
-
}));
|
|
3166
|
+
return jsxRuntime.jsxs("div", {
|
|
3167
|
+
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({}, props, {
|
|
3168
|
+
disabled: disabled || readonly,
|
|
3169
|
+
type: 'file',
|
|
3170
|
+
onChangeOverride: handleChange,
|
|
3171
|
+
value: '',
|
|
3172
|
+
accept: options.accept ? String(options.accept) : undefined
|
|
3173
|
+
})), jsxRuntime.jsx(FilesInfo, {
|
|
3174
|
+
filesInfo: filesInfo,
|
|
3175
|
+
registry: registry
|
|
3176
|
+
})]
|
|
3177
|
+
});
|
|
3039
3178
|
}
|
|
3040
3179
|
|
|
3041
3180
|
/** The `HiddenWidget` is a widget for rendering a hidden input field.
|
|
@@ -3046,11 +3185,11 @@ function FileWidget(_ref2) {
|
|
|
3046
3185
|
function HiddenWidget(_ref) {
|
|
3047
3186
|
var id = _ref.id,
|
|
3048
3187
|
value = _ref.value;
|
|
3049
|
-
return
|
|
3050
|
-
type:
|
|
3188
|
+
return jsxRuntime.jsx("input", {
|
|
3189
|
+
type: 'hidden',
|
|
3051
3190
|
id: id,
|
|
3052
3191
|
name: id,
|
|
3053
|
-
value: typeof value ===
|
|
3192
|
+
value: typeof value === 'undefined' ? '' : value
|
|
3054
3193
|
});
|
|
3055
3194
|
}
|
|
3056
3195
|
|
|
@@ -3061,9 +3200,9 @@ function HiddenWidget(_ref) {
|
|
|
3061
3200
|
function PasswordWidget(props) {
|
|
3062
3201
|
var options = props.options,
|
|
3063
3202
|
registry = props.registry;
|
|
3064
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3065
|
-
return
|
|
3066
|
-
type:
|
|
3203
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3204
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3205
|
+
type: 'password'
|
|
3067
3206
|
}, props));
|
|
3068
3207
|
}
|
|
3069
3208
|
|
|
@@ -3090,46 +3229,53 @@ function RadioWidget(_ref) {
|
|
|
3090
3229
|
enumDisabled = options.enumDisabled,
|
|
3091
3230
|
inline = options.inline,
|
|
3092
3231
|
emptyValue = options.emptyValue;
|
|
3093
|
-
var handleBlur =
|
|
3232
|
+
var handleBlur = react.useCallback(function (_ref2) {
|
|
3094
3233
|
var value = _ref2.target.value;
|
|
3095
3234
|
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3096
3235
|
}, [onBlur, id]);
|
|
3097
|
-
var handleFocus =
|
|
3236
|
+
var handleFocus = react.useCallback(function (_ref3) {
|
|
3098
3237
|
var value = _ref3.target.value;
|
|
3099
3238
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
3100
3239
|
}, [onFocus, id]);
|
|
3101
|
-
return
|
|
3102
|
-
className:
|
|
3103
|
-
id: id
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3240
|
+
return jsxRuntime.jsx("div", {
|
|
3241
|
+
className: 'field-radio-group',
|
|
3242
|
+
id: id,
|
|
3243
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
3244
|
+
var checked = utils.enumOptionsIsSelected(option.value, value);
|
|
3245
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3246
|
+
var disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
3247
|
+
var handleChange = function handleChange() {
|
|
3248
|
+
return onChange(option.value);
|
|
3249
|
+
};
|
|
3250
|
+
var radio = jsxRuntime.jsxs("span", {
|
|
3251
|
+
children: [jsxRuntime.jsx("input", {
|
|
3252
|
+
type: 'radio',
|
|
3253
|
+
id: utils.optionId(id, i),
|
|
3254
|
+
checked: checked,
|
|
3255
|
+
name: name,
|
|
3256
|
+
required: required,
|
|
3257
|
+
value: String(i),
|
|
3258
|
+
disabled: disabled || itemDisabled || readonly,
|
|
3259
|
+
autoFocus: autofocus && i === 0,
|
|
3260
|
+
onChange: handleChange,
|
|
3261
|
+
onBlur: handleBlur,
|
|
3262
|
+
onFocus: handleFocus,
|
|
3263
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3264
|
+
}), jsxRuntime.jsx("span", {
|
|
3265
|
+
children: option.label
|
|
3266
|
+
})]
|
|
3267
|
+
});
|
|
3268
|
+
return inline ? jsxRuntime.jsx("label", {
|
|
3269
|
+
className: "radio-inline " + disabledCls,
|
|
3270
|
+
children: radio
|
|
3271
|
+
}, i) : jsxRuntime.jsx("div", {
|
|
3272
|
+
className: "radio " + disabledCls,
|
|
3273
|
+
children: jsxRuntime.jsx("label", {
|
|
3274
|
+
children: radio
|
|
3275
|
+
})
|
|
3276
|
+
}, i);
|
|
3277
|
+
})
|
|
3278
|
+
});
|
|
3133
3279
|
}
|
|
3134
3280
|
|
|
3135
3281
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -3140,13 +3286,15 @@ function RadioWidget(_ref) {
|
|
|
3140
3286
|
function RangeWidget(props) {
|
|
3141
3287
|
var value = props.value,
|
|
3142
3288
|
BaseInputTemplate = props.registry.templates.BaseInputTemplate;
|
|
3143
|
-
return
|
|
3144
|
-
className:
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3289
|
+
return jsxRuntime.jsxs("div", {
|
|
3290
|
+
className: 'field-range-wrapper',
|
|
3291
|
+
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3292
|
+
type: 'range'
|
|
3293
|
+
}, props)), jsxRuntime.jsx("span", {
|
|
3294
|
+
className: 'range-view',
|
|
3295
|
+
children: value
|
|
3296
|
+
})]
|
|
3297
|
+
});
|
|
3150
3298
|
}
|
|
3151
3299
|
|
|
3152
3300
|
function getValue(event, multiple) {
|
|
@@ -3183,45 +3331,47 @@ function SelectWidget(_ref) {
|
|
|
3183
3331
|
var enumOptions = options.enumOptions,
|
|
3184
3332
|
enumDisabled = options.enumDisabled,
|
|
3185
3333
|
optEmptyVal = options.emptyValue;
|
|
3186
|
-
var emptyValue = multiple ? [] :
|
|
3187
|
-
var handleFocus =
|
|
3334
|
+
var emptyValue = multiple ? [] : '';
|
|
3335
|
+
var handleFocus = react.useCallback(function (event) {
|
|
3188
3336
|
var newValue = getValue(event, multiple);
|
|
3189
3337
|
return onFocus(id, utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3190
3338
|
}, [onFocus, id, schema, multiple, options]);
|
|
3191
|
-
var handleBlur =
|
|
3339
|
+
var handleBlur = react.useCallback(function (event) {
|
|
3192
3340
|
var newValue = getValue(event, multiple);
|
|
3193
3341
|
return onBlur(id, utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3194
3342
|
}, [onBlur, id, schema, multiple, options]);
|
|
3195
|
-
var handleChange =
|
|
3343
|
+
var handleChange = react.useCallback(function (event) {
|
|
3196
3344
|
var newValue = getValue(event, multiple);
|
|
3197
3345
|
return onChange(utils.enumOptionsValueForIndex(newValue, enumOptions, optEmptyVal));
|
|
3198
3346
|
}, [onChange, schema, multiple, options]);
|
|
3199
3347
|
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
3200
|
-
return
|
|
3348
|
+
return jsxRuntime.jsxs("select", {
|
|
3201
3349
|
id: id,
|
|
3202
3350
|
name: id,
|
|
3203
3351
|
multiple: multiple,
|
|
3204
|
-
className:
|
|
3205
|
-
value: typeof selectedIndexes ===
|
|
3352
|
+
className: 'form-control',
|
|
3353
|
+
value: typeof selectedIndexes === 'undefined' ? emptyValue : selectedIndexes,
|
|
3206
3354
|
required: required,
|
|
3207
3355
|
disabled: disabled || readonly,
|
|
3208
3356
|
autoFocus: autofocus,
|
|
3209
3357
|
onBlur: handleBlur,
|
|
3210
3358
|
onFocus: handleFocus,
|
|
3211
3359
|
onChange: handleChange,
|
|
3212
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3360
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
3361
|
+
children: [!multiple && schema["default"] === undefined && jsxRuntime.jsx("option", {
|
|
3362
|
+
value: '',
|
|
3363
|
+
children: placeholder
|
|
3364
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, i) {
|
|
3365
|
+
var value = _ref2.value,
|
|
3366
|
+
label = _ref2.label;
|
|
3367
|
+
var disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
|
|
3368
|
+
return jsxRuntime.jsx("option", {
|
|
3369
|
+
value: String(i),
|
|
3370
|
+
disabled: disabled,
|
|
3371
|
+
children: label
|
|
3372
|
+
}, i);
|
|
3373
|
+
})]
|
|
3374
|
+
});
|
|
3225
3375
|
}
|
|
3226
3376
|
|
|
3227
3377
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -3242,23 +3392,23 @@ function TextareaWidget(_ref) {
|
|
|
3242
3392
|
onChange = _ref.onChange,
|
|
3243
3393
|
onBlur = _ref.onBlur,
|
|
3244
3394
|
onFocus = _ref.onFocus;
|
|
3245
|
-
var handleChange =
|
|
3395
|
+
var handleChange = react.useCallback(function (_ref2) {
|
|
3246
3396
|
var value = _ref2.target.value;
|
|
3247
|
-
return onChange(value ===
|
|
3397
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
3248
3398
|
}, [onChange, options.emptyValue]);
|
|
3249
|
-
var handleBlur =
|
|
3399
|
+
var handleBlur = react.useCallback(function (_ref3) {
|
|
3250
3400
|
var value = _ref3.target.value;
|
|
3251
3401
|
return onBlur(id, value);
|
|
3252
3402
|
}, [onBlur, id]);
|
|
3253
|
-
var handleFocus =
|
|
3403
|
+
var handleFocus = react.useCallback(function (_ref4) {
|
|
3254
3404
|
var value = _ref4.target.value;
|
|
3255
3405
|
return onFocus(id, value);
|
|
3256
3406
|
}, [id, onFocus]);
|
|
3257
|
-
return
|
|
3407
|
+
return jsxRuntime.jsx("textarea", {
|
|
3258
3408
|
id: id,
|
|
3259
3409
|
name: id,
|
|
3260
|
-
className:
|
|
3261
|
-
value: value ? value :
|
|
3410
|
+
className: 'form-control',
|
|
3411
|
+
value: value ? value : '',
|
|
3262
3412
|
placeholder: placeholder,
|
|
3263
3413
|
required: required,
|
|
3264
3414
|
disabled: disabled,
|
|
@@ -3283,8 +3433,28 @@ TextareaWidget.defaultProps = {
|
|
|
3283
3433
|
function TextWidget(props) {
|
|
3284
3434
|
var options = props.options,
|
|
3285
3435
|
registry = props.registry;
|
|
3286
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3287
|
-
return
|
|
3436
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3437
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({}, props));
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
/** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
|
|
3441
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
3442
|
+
*
|
|
3443
|
+
* @param props - The `WidgetProps` for this component
|
|
3444
|
+
*/
|
|
3445
|
+
function TimeWidget(props) {
|
|
3446
|
+
var onChange = props.onChange,
|
|
3447
|
+
options = props.options,
|
|
3448
|
+
registry = props.registry;
|
|
3449
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3450
|
+
var handleChange = react.useCallback(function (value) {
|
|
3451
|
+
return onChange(value ? value + ":00" : undefined);
|
|
3452
|
+
}, [onChange]);
|
|
3453
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3454
|
+
type: 'time'
|
|
3455
|
+
}, props, {
|
|
3456
|
+
onChange: handleChange
|
|
3457
|
+
}));
|
|
3288
3458
|
}
|
|
3289
3459
|
|
|
3290
3460
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
@@ -3294,9 +3464,9 @@ function TextWidget(props) {
|
|
|
3294
3464
|
function URLWidget(props) {
|
|
3295
3465
|
var options = props.options,
|
|
3296
3466
|
registry = props.registry;
|
|
3297
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3298
|
-
return
|
|
3299
|
-
type:
|
|
3467
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3468
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3469
|
+
type: 'url'
|
|
3300
3470
|
}, props));
|
|
3301
3471
|
}
|
|
3302
3472
|
|
|
@@ -3307,32 +3477,33 @@ function URLWidget(props) {
|
|
|
3307
3477
|
function UpDownWidget(props) {
|
|
3308
3478
|
var options = props.options,
|
|
3309
3479
|
registry = props.registry;
|
|
3310
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
3311
|
-
return
|
|
3312
|
-
type:
|
|
3480
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3481
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3482
|
+
type: 'number'
|
|
3313
3483
|
}, props));
|
|
3314
3484
|
}
|
|
3315
3485
|
|
|
3316
3486
|
function widgets() {
|
|
3317
3487
|
return {
|
|
3488
|
+
AltDateWidget: AltDateWidget,
|
|
3489
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
3490
|
+
CheckboxWidget: CheckboxWidget,
|
|
3491
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
3492
|
+
ColorWidget: ColorWidget,
|
|
3493
|
+
DateWidget: DateWidget,
|
|
3494
|
+
DateTimeWidget: DateTimeWidget,
|
|
3495
|
+
EmailWidget: EmailWidget,
|
|
3496
|
+
FileWidget: FileWidget,
|
|
3497
|
+
HiddenWidget: HiddenWidget,
|
|
3318
3498
|
PasswordWidget: PasswordWidget,
|
|
3319
3499
|
RadioWidget: RadioWidget,
|
|
3320
|
-
UpDownWidget: UpDownWidget,
|
|
3321
3500
|
RangeWidget: RangeWidget,
|
|
3322
3501
|
SelectWidget: SelectWidget,
|
|
3323
3502
|
TextWidget: TextWidget,
|
|
3324
|
-
DateWidget: DateWidget,
|
|
3325
|
-
DateTimeWidget: DateTimeWidget,
|
|
3326
|
-
AltDateWidget: AltDateWidget,
|
|
3327
|
-
AltDateTimeWidget: AltDateTimeWidget,
|
|
3328
|
-
EmailWidget: EmailWidget,
|
|
3329
|
-
URLWidget: URLWidget,
|
|
3330
3503
|
TextareaWidget: TextareaWidget,
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
CheckboxWidget: CheckboxWidget,
|
|
3335
|
-
CheckboxesWidget: CheckboxesWidget
|
|
3504
|
+
TimeWidget: TimeWidget,
|
|
3505
|
+
UpDownWidget: UpDownWidget,
|
|
3506
|
+
URLWidget: URLWidget
|
|
3336
3507
|
};
|
|
3337
3508
|
}
|
|
3338
3509
|
|
|
@@ -3370,7 +3541,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3370
3541
|
_this.formElement = void 0;
|
|
3371
3542
|
_this.getUsedFormData = function (formData, fields) {
|
|
3372
3543
|
// For the case of a single input form
|
|
3373
|
-
if (fields.length === 0 && typeof formData !==
|
|
3544
|
+
if (fields.length === 0 && typeof formData !== 'object') {
|
|
3374
3545
|
return formData;
|
|
3375
3546
|
}
|
|
3376
3547
|
// _pick has incorrect type definition, it works with string[][], because lodash/hasIn supports it
|
|
@@ -3391,22 +3562,22 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3391
3562
|
paths = [[]];
|
|
3392
3563
|
}
|
|
3393
3564
|
Object.keys(_obj).forEach(function (key) {
|
|
3394
|
-
if (typeof _obj[key] ===
|
|
3565
|
+
if (typeof _obj[key] === 'object') {
|
|
3395
3566
|
var newPaths = paths.map(function (path) {
|
|
3396
3567
|
return [].concat(path, [key]);
|
|
3397
3568
|
});
|
|
3398
3569
|
// If an object is marked with additionalProperties, all its keys are valid
|
|
3399
|
-
if (_obj[key][utils.RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][utils.NAME_KEY] !==
|
|
3570
|
+
if (_obj[key][utils.RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][utils.NAME_KEY] !== '') {
|
|
3400
3571
|
acc.push(_obj[key][utils.NAME_KEY]);
|
|
3401
3572
|
} else {
|
|
3402
3573
|
getAllPaths(_obj[key], acc, newPaths);
|
|
3403
3574
|
}
|
|
3404
|
-
} else if (key === utils.NAME_KEY && _obj[key] !==
|
|
3575
|
+
} else if (key === utils.NAME_KEY && _obj[key] !== '') {
|
|
3405
3576
|
paths.forEach(function (path) {
|
|
3406
3577
|
var formValue = get__default["default"](formData, path);
|
|
3407
3578
|
// adds path to fieldNames if it points to a value
|
|
3408
3579
|
// or an empty object/array
|
|
3409
|
-
if (typeof formValue !==
|
|
3580
|
+
if (typeof formValue !== 'object' || isEmpty__default["default"](formValue)) {
|
|
3410
3581
|
acc.push(path);
|
|
3411
3582
|
}
|
|
3412
3583
|
});
|
|
@@ -3439,7 +3610,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3439
3610
|
var newFormData = formData;
|
|
3440
3611
|
if (omitExtraData === true && liveOmit === true) {
|
|
3441
3612
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3442
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3613
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
3443
3614
|
var fieldNames = _this.getFieldNames(pathSchema, formData);
|
|
3444
3615
|
newFormData = _this.getUsedFormData(formData, fieldNames);
|
|
3445
3616
|
state = {
|
|
@@ -3465,7 +3636,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3465
3636
|
schemaValidationErrorSchema: schemaValidationErrorSchema
|
|
3466
3637
|
};
|
|
3467
3638
|
} else if (!noValidate && newErrorSchema) {
|
|
3468
|
-
var _errorSchema = extraErrors ? utils.mergeObjects(newErrorSchema, extraErrors,
|
|
3639
|
+
var _errorSchema = extraErrors ? utils.mergeObjects(newErrorSchema, extraErrors, 'preventDuplicates') : newErrorSchema;
|
|
3469
3640
|
state = {
|
|
3470
3641
|
formData: newFormData,
|
|
3471
3642
|
errorSchema: _errorSchema,
|
|
@@ -3476,6 +3647,21 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3476
3647
|
return onChange && onChange(_extends({}, _this.state, state), id);
|
|
3477
3648
|
});
|
|
3478
3649
|
};
|
|
3650
|
+
_this.reset = function () {
|
|
3651
|
+
var onChange = _this.props.onChange;
|
|
3652
|
+
var newState = _this.getStateFromProps(_this.props, undefined);
|
|
3653
|
+
var newFormData = newState.formData;
|
|
3654
|
+
var state = {
|
|
3655
|
+
formData: newFormData,
|
|
3656
|
+
errorSchema: {},
|
|
3657
|
+
errors: [],
|
|
3658
|
+
schemaValidationErrors: [],
|
|
3659
|
+
schemaValidationErrorSchema: {}
|
|
3660
|
+
};
|
|
3661
|
+
_this.setState(state, function () {
|
|
3662
|
+
return onChange && onChange(_extends({}, _this.state, state));
|
|
3663
|
+
});
|
|
3664
|
+
};
|
|
3479
3665
|
_this.onBlur = function (id, data) {
|
|
3480
3666
|
var onBlur = _this.props.onBlur;
|
|
3481
3667
|
if (onBlur) {
|
|
@@ -3505,7 +3691,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3505
3691
|
schemaUtils = _this$state2.schemaUtils;
|
|
3506
3692
|
if (omitExtraData === true) {
|
|
3507
3693
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, newFormData);
|
|
3508
|
-
var pathSchema = schemaUtils.toPathSchema(retrievedSchema,
|
|
3694
|
+
var pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', newFormData);
|
|
3509
3695
|
var fieldNames = _this.getFieldNames(pathSchema, newFormData);
|
|
3510
3696
|
newFormData = _this.getUsedFormData(newFormData, fieldNames);
|
|
3511
3697
|
}
|
|
@@ -3524,20 +3710,20 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3524
3710
|
if (onSubmit) {
|
|
3525
3711
|
onSubmit(_extends({}, _this.state, {
|
|
3526
3712
|
formData: newFormData,
|
|
3527
|
-
status:
|
|
3713
|
+
status: 'submitted'
|
|
3528
3714
|
}), event);
|
|
3529
3715
|
}
|
|
3530
3716
|
});
|
|
3531
3717
|
}
|
|
3532
3718
|
};
|
|
3533
3719
|
if (!props.validator) {
|
|
3534
|
-
throw new Error(
|
|
3720
|
+
throw new Error('A validator is required for Form functionality to work');
|
|
3535
3721
|
}
|
|
3536
3722
|
_this.state = _this.getStateFromProps(props, props.formData);
|
|
3537
3723
|
if (_this.props.onChange && !utils.deepEquals(_this.state.formData, _this.props.formData)) {
|
|
3538
3724
|
_this.props.onChange(_this.state);
|
|
3539
3725
|
}
|
|
3540
|
-
_this.formElement = /*#__PURE__*/
|
|
3726
|
+
_this.formElement = /*#__PURE__*/react.createRef();
|
|
3541
3727
|
return _this;
|
|
3542
3728
|
}
|
|
3543
3729
|
/** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
|
|
@@ -3564,10 +3750,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3564
3750
|
*/;
|
|
3565
3751
|
_proto.getStateFromProps = function getStateFromProps(props, inputFormData) {
|
|
3566
3752
|
var state = this.state || {};
|
|
3567
|
-
var schema =
|
|
3568
|
-
var uiSchema = (
|
|
3569
|
-
var edit = typeof inputFormData !==
|
|
3570
|
-
var liveValidate =
|
|
3753
|
+
var schema = 'schema' in props ? props.schema : this.props.schema;
|
|
3754
|
+
var uiSchema = ('uiSchema' in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
3755
|
+
var edit = typeof inputFormData !== 'undefined';
|
|
3756
|
+
var liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
3571
3757
|
var mustValidate = edit && !props.noValidate && liveValidate;
|
|
3572
3758
|
var rootSchema = schema;
|
|
3573
3759
|
var schemaUtils = state.schemaUtils;
|
|
@@ -3616,7 +3802,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3616
3802
|
errorSchema = merged.errorSchema;
|
|
3617
3803
|
errors = merged.errors;
|
|
3618
3804
|
}
|
|
3619
|
-
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema[
|
|
3805
|
+
var idSchema = schemaUtils.toIdSchema(retrievedSchema, uiSchema['ui:rootFieldId'], formData, props.idPrefix, props.idSeparator);
|
|
3620
3806
|
var nextState = {
|
|
3621
3807
|
schemaUtils: schemaUtils,
|
|
3622
3808
|
schema: schema,
|
|
@@ -3668,9 +3854,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3668
3854
|
uiSchema = _this$state3.uiSchema;
|
|
3669
3855
|
var formContext = this.props.formContext;
|
|
3670
3856
|
var options = utils.getUiOptions(uiSchema);
|
|
3671
|
-
var ErrorListTemplate = utils.getTemplate(
|
|
3857
|
+
var ErrorListTemplate = utils.getTemplate('ErrorListTemplate', registry, options);
|
|
3672
3858
|
if (errors && errors.length) {
|
|
3673
|
-
return
|
|
3859
|
+
return jsxRuntime.jsx(ErrorListTemplate, {
|
|
3674
3860
|
errors: errors,
|
|
3675
3861
|
errorSchema: errorSchema || {},
|
|
3676
3862
|
schema: schema,
|
|
@@ -3689,7 +3875,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3689
3875
|
/** Returns the registry for the form */
|
|
3690
3876
|
_proto.getRegistry = function getRegistry() {
|
|
3691
3877
|
var _this$props$templates;
|
|
3692
|
-
var
|
|
3878
|
+
var _this$props4 = this.props,
|
|
3879
|
+
customTranslateString = _this$props4.translateString,
|
|
3880
|
+
_this$props4$uiSchema = _this$props4.uiSchema,
|
|
3881
|
+
uiSchema = _this$props4$uiSchema === void 0 ? {} : _this$props4$uiSchema;
|
|
3693
3882
|
var schemaUtils = this.state.schemaUtils;
|
|
3694
3883
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3695
3884
|
fields = _getDefaultRegistry.fields,
|
|
@@ -3706,13 +3895,14 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3706
3895
|
rootSchema: this.props.schema,
|
|
3707
3896
|
formContext: this.props.formContext || formContext,
|
|
3708
3897
|
schemaUtils: schemaUtils,
|
|
3709
|
-
translateString: customTranslateString || translateString
|
|
3898
|
+
translateString: customTranslateString || translateString,
|
|
3899
|
+
globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY]
|
|
3710
3900
|
};
|
|
3711
3901
|
}
|
|
3712
3902
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
3713
3903
|
_proto.submit = function submit() {
|
|
3714
3904
|
if (this.formElement.current) {
|
|
3715
|
-
this.formElement.current.dispatchEvent(new CustomEvent(
|
|
3905
|
+
this.formElement.current.dispatchEvent(new CustomEvent('submit', {
|
|
3716
3906
|
cancelable: true
|
|
3717
3907
|
}));
|
|
3718
3908
|
this.formElement.current.requestSubmit();
|
|
@@ -3725,14 +3915,14 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3725
3915
|
* @param error - The error on which to focus
|
|
3726
3916
|
*/;
|
|
3727
3917
|
_proto.focusOnError = function focusOnError(error) {
|
|
3728
|
-
var _this$
|
|
3729
|
-
_this$
|
|
3730
|
-
idPrefix = _this$
|
|
3731
|
-
_this$
|
|
3732
|
-
idSeparator = _this$
|
|
3918
|
+
var _this$props5 = this.props,
|
|
3919
|
+
_this$props5$idPrefix = _this$props5.idPrefix,
|
|
3920
|
+
idPrefix = _this$props5$idPrefix === void 0 ? 'root' : _this$props5$idPrefix,
|
|
3921
|
+
_this$props5$idSepara = _this$props5.idSeparator,
|
|
3922
|
+
idSeparator = _this$props5$idSepara === void 0 ? '_' : _this$props5$idSepara;
|
|
3733
3923
|
var property = error.property;
|
|
3734
3924
|
var path = _toPath__default["default"](property);
|
|
3735
|
-
if (path[0] ===
|
|
3925
|
+
if (path[0] === '') {
|
|
3736
3926
|
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3737
3927
|
path[0] = idPrefix;
|
|
3738
3928
|
} else {
|
|
@@ -3755,10 +3945,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3755
3945
|
* @returns - True if the form is valid, false otherwise.
|
|
3756
3946
|
*/;
|
|
3757
3947
|
_proto.validateForm = function validateForm() {
|
|
3758
|
-
var _this$
|
|
3759
|
-
extraErrors = _this$
|
|
3760
|
-
focusOnFirstError = _this$
|
|
3761
|
-
onError = _this$
|
|
3948
|
+
var _this$props6 = this.props,
|
|
3949
|
+
extraErrors = _this$props6.extraErrors,
|
|
3950
|
+
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
3951
|
+
onError = _this$props6.onError;
|
|
3762
3952
|
var formData = this.state.formData;
|
|
3763
3953
|
var schemaUtils = this.state.schemaUtils;
|
|
3764
3954
|
var schemaValidation = this.validate(formData);
|
|
@@ -3784,7 +3974,7 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3784
3974
|
if (onError) {
|
|
3785
3975
|
onError(errors);
|
|
3786
3976
|
} else {
|
|
3787
|
-
console.error(
|
|
3977
|
+
console.error('Form validation failed', errors);
|
|
3788
3978
|
}
|
|
3789
3979
|
});
|
|
3790
3980
|
return false;
|
|
@@ -3795,31 +3985,31 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3795
3985
|
* needed along with the submit button or any children of the form.
|
|
3796
3986
|
*/;
|
|
3797
3987
|
_proto.render = function render() {
|
|
3798
|
-
var _this$
|
|
3799
|
-
children = _this$
|
|
3800
|
-
id = _this$
|
|
3801
|
-
idPrefix = _this$
|
|
3802
|
-
idSeparator = _this$
|
|
3803
|
-
_this$
|
|
3804
|
-
className = _this$
|
|
3805
|
-
tagName = _this$
|
|
3806
|
-
name = _this$
|
|
3807
|
-
method = _this$
|
|
3808
|
-
target = _this$
|
|
3809
|
-
action = _this$
|
|
3810
|
-
autoComplete = _this$
|
|
3811
|
-
enctype = _this$
|
|
3812
|
-
acceptcharset = _this$
|
|
3813
|
-
_this$
|
|
3814
|
-
noHtml5Validate = _this$
|
|
3815
|
-
_this$
|
|
3816
|
-
disabled = _this$
|
|
3817
|
-
_this$
|
|
3818
|
-
readonly = _this$
|
|
3819
|
-
formContext = _this$
|
|
3820
|
-
_this$
|
|
3821
|
-
showErrorList = _this$
|
|
3822
|
-
_internalFormWrapper = _this$
|
|
3988
|
+
var _this$props7 = this.props,
|
|
3989
|
+
children = _this$props7.children,
|
|
3990
|
+
id = _this$props7.id,
|
|
3991
|
+
idPrefix = _this$props7.idPrefix,
|
|
3992
|
+
idSeparator = _this$props7.idSeparator,
|
|
3993
|
+
_this$props7$classNam = _this$props7.className,
|
|
3994
|
+
className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
|
|
3995
|
+
tagName = _this$props7.tagName,
|
|
3996
|
+
name = _this$props7.name,
|
|
3997
|
+
method = _this$props7.method,
|
|
3998
|
+
target = _this$props7.target,
|
|
3999
|
+
action = _this$props7.action,
|
|
4000
|
+
autoComplete = _this$props7.autoComplete,
|
|
4001
|
+
enctype = _this$props7.enctype,
|
|
4002
|
+
acceptcharset = _this$props7.acceptcharset,
|
|
4003
|
+
_this$props7$noHtml5V = _this$props7.noHtml5Validate,
|
|
4004
|
+
noHtml5Validate = _this$props7$noHtml5V === void 0 ? false : _this$props7$noHtml5V,
|
|
4005
|
+
_this$props7$disabled = _this$props7.disabled,
|
|
4006
|
+
disabled = _this$props7$disabled === void 0 ? false : _this$props7$disabled,
|
|
4007
|
+
_this$props7$readonly = _this$props7.readonly,
|
|
4008
|
+
readonly = _this$props7$readonly === void 0 ? false : _this$props7$readonly,
|
|
4009
|
+
formContext = _this$props7.formContext,
|
|
4010
|
+
_this$props7$showErro = _this$props7.showErrorList,
|
|
4011
|
+
showErrorList = _this$props7$showErro === void 0 ? 'top' : _this$props7$showErro,
|
|
4012
|
+
_internalFormWrapper = _this$props7._internalFormWrapper;
|
|
3823
4013
|
var _this$state4 = this.state,
|
|
3824
4014
|
schema = _this$state4.schema,
|
|
3825
4015
|
uiSchema = _this$state4.uiSchema,
|
|
@@ -3833,9 +4023,9 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3833
4023
|
// PropTypes.elementType to use for the inner tag, so we'll need to pass `tagName` along if it is provided.
|
|
3834
4024
|
// NOTE, the `as` prop is native to `semantic-ui` and is emulated in the `material-ui` theme
|
|
3835
4025
|
var as = _internalFormWrapper ? tagName : undefined;
|
|
3836
|
-
var FormTag = _internalFormWrapper || tagName ||
|
|
3837
|
-
return
|
|
3838
|
-
className: className ? className :
|
|
4026
|
+
var FormTag = _internalFormWrapper || tagName || 'form';
|
|
4027
|
+
return jsxRuntime.jsxs(FormTag, {
|
|
4028
|
+
className: className ? className : 'rjsf',
|
|
3839
4029
|
id: id,
|
|
3840
4030
|
name: name,
|
|
3841
4031
|
method: method,
|
|
@@ -3847,35 +4037,36 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3847
4037
|
noValidate: noHtml5Validate,
|
|
3848
4038
|
onSubmit: this.onSubmit,
|
|
3849
4039
|
as: as,
|
|
3850
|
-
ref: this.formElement
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
4040
|
+
ref: this.formElement,
|
|
4041
|
+
children: [showErrorList === 'top' && this.renderErrors(registry), jsxRuntime.jsx(_SchemaField, {
|
|
4042
|
+
name: '',
|
|
4043
|
+
schema: schema,
|
|
4044
|
+
uiSchema: uiSchema,
|
|
4045
|
+
errorSchema: errorSchema,
|
|
4046
|
+
idSchema: idSchema,
|
|
4047
|
+
idPrefix: idPrefix,
|
|
4048
|
+
idSeparator: idSeparator,
|
|
4049
|
+
formContext: formContext,
|
|
4050
|
+
formData: formData,
|
|
4051
|
+
onChange: this.onChange,
|
|
4052
|
+
onBlur: this.onBlur,
|
|
4053
|
+
onFocus: this.onFocus,
|
|
4054
|
+
registry: registry,
|
|
4055
|
+
disabled: disabled,
|
|
4056
|
+
readonly: readonly
|
|
4057
|
+
}), children ? children : jsxRuntime.jsx(SubmitButton, {
|
|
4058
|
+
uiSchema: uiSchema,
|
|
4059
|
+
registry: registry
|
|
4060
|
+
}), showErrorList === 'bottom' && this.renderErrors(registry)]
|
|
4061
|
+
});
|
|
3871
4062
|
};
|
|
3872
4063
|
return Form;
|
|
3873
|
-
}(
|
|
4064
|
+
}(react.Component);
|
|
3874
4065
|
|
|
3875
4066
|
var _excluded = ["fields", "widgets", "templates"];
|
|
3876
4067
|
/** A Higher-Order component that creates a wrapper around a `Form` with the overrides from the `WithThemeProps` */
|
|
3877
4068
|
function withTheme(themeProps) {
|
|
3878
|
-
return /*#__PURE__*/
|
|
4069
|
+
return /*#__PURE__*/react.forwardRef(function (_ref, ref) {
|
|
3879
4070
|
var _themeProps$templates, _templates;
|
|
3880
4071
|
var fields = _ref.fields,
|
|
3881
4072
|
widgets = _ref.widgets,
|
|
@@ -3886,7 +4077,7 @@ function withTheme(themeProps) {
|
|
|
3886
4077
|
templates = _extends({}, themeProps === null || themeProps === void 0 ? void 0 : themeProps.templates, templates, {
|
|
3887
4078
|
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)
|
|
3888
4079
|
});
|
|
3889
|
-
return
|
|
4080
|
+
return jsxRuntime.jsx(Form, _extends({}, themeProps, directProps, {
|
|
3890
4081
|
fields: fields,
|
|
3891
4082
|
widgets: widgets,
|
|
3892
4083
|
templates: templates,
|