@rjsf/core 5.3.1 → 5.5.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/dist/core.cjs.development.js +134 -54
- 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 +135 -55
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +134 -54
- 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/package.json +12 -9
package/dist/core.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Component, useState, useCallback, useEffect, useReducer, useMemo, createRef, forwardRef } from 'react';
|
|
3
|
-
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, UI_GLOBAL_OPTIONS_KEY, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
|
|
3
|
+
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, labelValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, UI_GLOBAL_OPTIONS_KEY, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
|
|
4
4
|
import get from 'lodash-es/get';
|
|
5
5
|
import isEmpty from 'lodash-es/isEmpty';
|
|
6
6
|
import _pick from 'lodash-es/pick';
|
|
@@ -84,9 +84,9 @@ function _toPropertyKey(arg) {
|
|
|
84
84
|
return typeof key === "symbol" ? key : String(key);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
var _excluded$9 = ["widget"],
|
|
88
|
-
_excluded2 = ["widget"],
|
|
89
|
-
_excluded3 = ["widget"];
|
|
87
|
+
var _excluded$9 = ["widget", "title"],
|
|
88
|
+
_excluded2 = ["widget", "title"],
|
|
89
|
+
_excluded3 = ["widget", "title"];
|
|
90
90
|
/** Used to generate a unique ID for an element in a row */
|
|
91
91
|
function generateRowId() {
|
|
92
92
|
return nanoid();
|
|
@@ -507,6 +507,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
507
507
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
508
508
|
*/;
|
|
509
509
|
_proto.renderCustomWidget = function renderCustomWidget() {
|
|
510
|
+
var _ref;
|
|
510
511
|
var _this$props9 = this.props,
|
|
511
512
|
schema = _this$props9.schema,
|
|
512
513
|
idSchema = _this$props9.idSchema,
|
|
@@ -529,12 +530,16 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
529
530
|
rawErrors = _this$props9.rawErrors,
|
|
530
531
|
name = _this$props9.name;
|
|
531
532
|
var widgets = registry.widgets,
|
|
532
|
-
formContext = registry.formContext
|
|
533
|
-
|
|
534
|
-
|
|
533
|
+
formContext = registry.formContext,
|
|
534
|
+
globalUiOptions = registry.globalUiOptions,
|
|
535
|
+
schemaUtils = registry.schemaUtils;
|
|
536
|
+
var _getUiOptions2 = getUiOptions(uiSchema, globalUiOptions),
|
|
535
537
|
widget = _getUiOptions2.widget,
|
|
538
|
+
uiTitle = _getUiOptions2.title,
|
|
536
539
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
537
540
|
var Widget = getWidget(schema, widget, widgets);
|
|
541
|
+
var label = (_ref = uiTitle != null ? uiTitle : schema.title) != null ? _ref : name;
|
|
542
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
538
543
|
return jsx(Widget, {
|
|
539
544
|
id: idSchema.$id,
|
|
540
545
|
name: name,
|
|
@@ -551,7 +556,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
551
556
|
readonly: readonly,
|
|
552
557
|
hideError: hideError,
|
|
553
558
|
required: required,
|
|
554
|
-
label:
|
|
559
|
+
label: label,
|
|
560
|
+
hideLabel: !displayLabel,
|
|
555
561
|
placeholder: placeholder,
|
|
556
562
|
formContext: formContext,
|
|
557
563
|
autofocus: autofocus,
|
|
@@ -561,6 +567,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
561
567
|
/** Renders an array as a set of checkboxes
|
|
562
568
|
*/;
|
|
563
569
|
_proto.renderMultiSelect = function renderMultiSelect() {
|
|
570
|
+
var _ref2;
|
|
564
571
|
var _this$props10 = this.props,
|
|
565
572
|
schema = _this$props10.schema,
|
|
566
573
|
idSchema = _this$props10.idSchema,
|
|
@@ -583,15 +590,18 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
583
590
|
name = _this$props10.name;
|
|
584
591
|
var widgets = registry.widgets,
|
|
585
592
|
schemaUtils = registry.schemaUtils,
|
|
586
|
-
formContext = registry.formContext
|
|
593
|
+
formContext = registry.formContext,
|
|
594
|
+
globalUiOptions = registry.globalUiOptions;
|
|
587
595
|
var itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
588
|
-
var title = schema.title || name;
|
|
589
596
|
var enumOptions = optionsList(itemsSchema);
|
|
590
|
-
var _getUiOptions3 = getUiOptions(uiSchema),
|
|
597
|
+
var _getUiOptions3 = getUiOptions(uiSchema, globalUiOptions),
|
|
591
598
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
592
599
|
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
600
|
+
uiTitle = _getUiOptions3.title,
|
|
593
601
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
594
602
|
var Widget = getWidget(schema, widget, widgets);
|
|
603
|
+
var label = (_ref2 = uiTitle != null ? uiTitle : schema.title) != null ? _ref2 : name;
|
|
604
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
595
605
|
return jsx(Widget, {
|
|
596
606
|
id: idSchema.$id,
|
|
597
607
|
name: name,
|
|
@@ -609,7 +619,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
609
619
|
disabled: disabled,
|
|
610
620
|
readonly: readonly,
|
|
611
621
|
required: required,
|
|
612
|
-
label:
|
|
622
|
+
label: label,
|
|
623
|
+
hideLabel: !displayLabel,
|
|
613
624
|
placeholder: placeholder,
|
|
614
625
|
formContext: formContext,
|
|
615
626
|
autofocus: autofocus,
|
|
@@ -619,6 +630,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
619
630
|
/** Renders an array of files using the `FileWidget`
|
|
620
631
|
*/;
|
|
621
632
|
_proto.renderFiles = function renderFiles() {
|
|
633
|
+
var _ref3;
|
|
622
634
|
var _this$props11 = this.props,
|
|
623
635
|
schema = _this$props11.schema,
|
|
624
636
|
uiSchema = _this$props11.uiSchema,
|
|
@@ -638,14 +650,18 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
638
650
|
_this$props11$formDat = _this$props11.formData,
|
|
639
651
|
items = _this$props11$formDat === void 0 ? [] : _this$props11$formDat,
|
|
640
652
|
rawErrors = _this$props11.rawErrors;
|
|
641
|
-
var title = schema.title || name;
|
|
642
653
|
var widgets = registry.widgets,
|
|
643
|
-
formContext = registry.formContext
|
|
644
|
-
|
|
654
|
+
formContext = registry.formContext,
|
|
655
|
+
globalUiOptions = registry.globalUiOptions,
|
|
656
|
+
schemaUtils = registry.schemaUtils;
|
|
657
|
+
var _getUiOptions4 = getUiOptions(uiSchema, globalUiOptions),
|
|
645
658
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
646
659
|
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
660
|
+
uiTitle = _getUiOptions4.title,
|
|
647
661
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
648
662
|
var Widget = getWidget(schema, widget, widgets);
|
|
663
|
+
var label = (_ref3 = uiTitle != null ? uiTitle : schema.title) != null ? _ref3 : name;
|
|
664
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
649
665
|
return jsx(Widget, {
|
|
650
666
|
options: options,
|
|
651
667
|
id: idSchema.$id,
|
|
@@ -656,7 +672,6 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
656
672
|
onFocus: onFocus,
|
|
657
673
|
schema: schema,
|
|
658
674
|
uiSchema: uiSchema,
|
|
659
|
-
title: title,
|
|
660
675
|
value: items,
|
|
661
676
|
disabled: disabled,
|
|
662
677
|
readonly: readonly,
|
|
@@ -665,7 +680,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
665
680
|
formContext: formContext,
|
|
666
681
|
autofocus: autofocus,
|
|
667
682
|
rawErrors: rawErrors,
|
|
668
|
-
label:
|
|
683
|
+
label: label,
|
|
684
|
+
hideLabel: !displayLabel
|
|
669
685
|
});
|
|
670
686
|
}
|
|
671
687
|
/** Renders an array that has a maximum limit of items
|
|
@@ -877,13 +893,14 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
877
893
|
return ArrayField;
|
|
878
894
|
}(Component);
|
|
879
895
|
|
|
880
|
-
var _excluded$8 = ["widget"];
|
|
896
|
+
var _excluded$8 = ["widget", "title", "label"];
|
|
881
897
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
882
898
|
* two boolean values based on the various alternatives in the schema.
|
|
883
899
|
*
|
|
884
900
|
* @param props - The `FieldProps` for this template
|
|
885
901
|
*/
|
|
886
902
|
function BooleanField(props) {
|
|
903
|
+
var _ref;
|
|
887
904
|
var schema = props.schema,
|
|
888
905
|
name = props.name,
|
|
889
906
|
uiSchema = props.uiSchema,
|
|
@@ -901,15 +918,20 @@ function BooleanField(props) {
|
|
|
901
918
|
var title = schema.title;
|
|
902
919
|
var widgets = registry.widgets,
|
|
903
920
|
formContext = registry.formContext,
|
|
904
|
-
translateString = registry.translateString
|
|
905
|
-
|
|
921
|
+
translateString = registry.translateString,
|
|
922
|
+
globalUiOptions = registry.globalUiOptions;
|
|
923
|
+
var _getUiOptions = getUiOptions(uiSchema, globalUiOptions),
|
|
906
924
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
907
925
|
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
926
|
+
uiTitle = _getUiOptions.title,
|
|
927
|
+
_getUiOptions$label = _getUiOptions.label,
|
|
928
|
+
displayLabel = _getUiOptions$label === void 0 ? true : _getUiOptions$label,
|
|
908
929
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
909
930
|
var Widget = getWidget(schema, widget, widgets);
|
|
910
931
|
var yes = translateString(TranslatableString.YesLabel);
|
|
911
932
|
var no = translateString(TranslatableString.NoLabel);
|
|
912
933
|
var enumOptions;
|
|
934
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
913
935
|
if (Array.isArray(schema.oneOf)) {
|
|
914
936
|
enumOptions = optionsList({
|
|
915
937
|
oneOf: schema.oneOf.map(function (option) {
|
|
@@ -957,7 +979,8 @@ function BooleanField(props) {
|
|
|
957
979
|
onChange: onChange,
|
|
958
980
|
onFocus: onFocus,
|
|
959
981
|
onBlur: onBlur,
|
|
960
|
-
label:
|
|
982
|
+
label: label,
|
|
983
|
+
hideLabel: !displayLabel,
|
|
961
984
|
value: formData,
|
|
962
985
|
required: required,
|
|
963
986
|
disabled: disabled,
|
|
@@ -1110,12 +1133,14 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1110
1133
|
uiSchema = _this$props5.uiSchema;
|
|
1111
1134
|
var widgets = registry.widgets,
|
|
1112
1135
|
fields = registry.fields,
|
|
1113
|
-
translateString = registry.translateString
|
|
1136
|
+
translateString = registry.translateString,
|
|
1137
|
+
globalUiOptions = registry.globalUiOptions,
|
|
1138
|
+
schemaUtils = registry.schemaUtils;
|
|
1114
1139
|
var _SchemaField = fields.SchemaField;
|
|
1115
1140
|
var _this$state2 = this.state,
|
|
1116
1141
|
selectedOption = _this$state2.selectedOption,
|
|
1117
1142
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1118
|
-
var _getUiOptions = getUiOptions(uiSchema),
|
|
1143
|
+
var _getUiOptions = getUiOptions(uiSchema, globalUiOptions),
|
|
1119
1144
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1120
1145
|
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1121
1146
|
placeholder = _getUiOptions.placeholder,
|
|
@@ -1129,6 +1154,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1129
1154
|
}, widget, widgets);
|
|
1130
1155
|
var rawErrors = get(errorSchema, ERRORS_KEY, []);
|
|
1131
1156
|
var fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
|
|
1157
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1132
1158
|
var option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1133
1159
|
var optionSchema;
|
|
1134
1160
|
if (option) {
|
|
@@ -1173,7 +1199,8 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1173
1199
|
placeholder: placeholder,
|
|
1174
1200
|
autocomplete: autocomplete,
|
|
1175
1201
|
autofocus: autofocus,
|
|
1176
|
-
label:
|
|
1202
|
+
label: title != null ? title : name,
|
|
1203
|
+
hideLabel: !displayLabel
|
|
1177
1204
|
})
|
|
1178
1205
|
}), option !== null && jsx(_SchemaField, _extends({}, this.props, {
|
|
1179
1206
|
schema: optionSchema
|
|
@@ -1428,7 +1455,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1428
1455
|
/** Renders the `ObjectField` from the given props
|
|
1429
1456
|
*/
|
|
1430
1457
|
_proto.render = function render() {
|
|
1431
|
-
var
|
|
1458
|
+
var _ref2,
|
|
1459
|
+
_uiOptions$title,
|
|
1460
|
+
_uiOptions$descriptio,
|
|
1461
|
+
_this2 = this;
|
|
1432
1462
|
var _this$props6 = this.props,
|
|
1433
1463
|
rawSchema = _this$props6.schema,
|
|
1434
1464
|
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
@@ -1452,14 +1482,15 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1452
1482
|
var fields = registry.fields,
|
|
1453
1483
|
formContext = registry.formContext,
|
|
1454
1484
|
schemaUtils = registry.schemaUtils,
|
|
1455
|
-
translateString = registry.translateString
|
|
1485
|
+
translateString = registry.translateString,
|
|
1486
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1456
1487
|
var SchemaField = fields.SchemaField;
|
|
1457
1488
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1458
|
-
var uiOptions = getUiOptions(uiSchema);
|
|
1489
|
+
var uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
1459
1490
|
var _schema$properties = schema.properties,
|
|
1460
1491
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1461
|
-
var title =
|
|
1462
|
-
var description = uiOptions.description
|
|
1492
|
+
var title = (_ref2 = (_uiOptions$title = uiOptions.title) != null ? _uiOptions$title : schema.title) != null ? _ref2 : name;
|
|
1493
|
+
var description = (_uiOptions$descriptio = uiOptions.description) != null ? _uiOptions$descriptio : schema.description;
|
|
1463
1494
|
var orderedProperties;
|
|
1464
1495
|
try {
|
|
1465
1496
|
var properties = Object.keys(schemaProperties);
|
|
@@ -1481,8 +1512,9 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1481
1512
|
}
|
|
1482
1513
|
var Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1483
1514
|
var templateProps = {
|
|
1484
|
-
|
|
1485
|
-
|
|
1515
|
+
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
1516
|
+
title: uiOptions.label === false ? '' : title,
|
|
1517
|
+
description: uiOptions.label === false ? undefined : description,
|
|
1486
1518
|
properties: orderedProperties.map(function (name) {
|
|
1487
1519
|
var addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
|
|
1488
1520
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
@@ -1523,6 +1555,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1523
1555
|
required: required,
|
|
1524
1556
|
idSchema: idSchema,
|
|
1525
1557
|
uiSchema: uiSchema,
|
|
1558
|
+
errorSchema: errorSchema,
|
|
1526
1559
|
schema: schema,
|
|
1527
1560
|
formData: formData,
|
|
1528
1561
|
formContext: formContext,
|
|
@@ -1799,12 +1832,13 @@ var SchemaField = /*#__PURE__*/function (_Component) {
|
|
|
1799
1832
|
return SchemaField;
|
|
1800
1833
|
}(Component);
|
|
1801
1834
|
|
|
1802
|
-
var _excluded$5 = ["widget", "placeholder"];
|
|
1835
|
+
var _excluded$5 = ["widget", "placeholder", "title"];
|
|
1803
1836
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
1804
1837
|
*
|
|
1805
1838
|
* @param props - The `FieldProps` for this template
|
|
1806
1839
|
*/
|
|
1807
1840
|
function StringField(props) {
|
|
1841
|
+
var _ref;
|
|
1808
1842
|
var schema = props.schema,
|
|
1809
1843
|
name = props.name,
|
|
1810
1844
|
uiSchema = props.uiSchema,
|
|
@@ -1826,7 +1860,8 @@ function StringField(props) {
|
|
|
1826
1860
|
format = schema.format;
|
|
1827
1861
|
var widgets = registry.widgets,
|
|
1828
1862
|
formContext = registry.formContext,
|
|
1829
|
-
schemaUtils = registry.schemaUtils
|
|
1863
|
+
schemaUtils = registry.schemaUtils,
|
|
1864
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1830
1865
|
var enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema) : undefined;
|
|
1831
1866
|
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1832
1867
|
if (format && hasWidget(schema, format, widgets)) {
|
|
@@ -1837,7 +1872,10 @@ function StringField(props) {
|
|
|
1837
1872
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1838
1873
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1839
1874
|
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1875
|
+
uiTitle = _getUiOptions.title,
|
|
1840
1876
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1877
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1878
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
1841
1879
|
var Widget = getWidget(schema, widget, widgets);
|
|
1842
1880
|
return jsx(Widget, {
|
|
1843
1881
|
options: _extends({}, options, {
|
|
@@ -1847,7 +1885,8 @@ function StringField(props) {
|
|
|
1847
1885
|
uiSchema: uiSchema,
|
|
1848
1886
|
id: idSchema.$id,
|
|
1849
1887
|
name: name,
|
|
1850
|
-
label:
|
|
1888
|
+
label: label,
|
|
1889
|
+
hideLabel: !displayLabel,
|
|
1851
1890
|
value: formData,
|
|
1852
1891
|
onChange: onChange,
|
|
1853
1892
|
onBlur: onBlur,
|
|
@@ -1905,7 +1944,7 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1905
1944
|
registry = props.registry,
|
|
1906
1945
|
schema = props.schema,
|
|
1907
1946
|
uiSchema = props.uiSchema;
|
|
1908
|
-
var options = getUiOptions(uiSchema);
|
|
1947
|
+
var options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
1909
1948
|
var _options$label = options.label,
|
|
1910
1949
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
1911
1950
|
if (!description || !displayLabel) {
|
|
@@ -2064,7 +2103,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2064
2103
|
uiSchema = props.uiSchema,
|
|
2065
2104
|
required = props.required,
|
|
2066
2105
|
registry = props.registry;
|
|
2067
|
-
var options = getUiOptions(uiSchema);
|
|
2106
|
+
var options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
2068
2107
|
var _options$label = options.label,
|
|
2069
2108
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
2070
2109
|
if (!title || !displayLabel) {
|
|
@@ -2081,7 +2120,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2081
2120
|
});
|
|
2082
2121
|
}
|
|
2083
2122
|
|
|
2084
|
-
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2123
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type", "hideLabel", "hideError"];
|
|
2085
2124
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2086
2125
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2087
2126
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2169,7 +2208,7 @@ function SubmitButton(_ref) {
|
|
|
2169
2208
|
children: jsx("button", _extends({
|
|
2170
2209
|
type: 'submit'
|
|
2171
2210
|
}, submitButtonProps, {
|
|
2172
|
-
className: "btn btn-info " + submitButtonProps.className,
|
|
2211
|
+
className: "btn btn-info " + (submitButtonProps.className || ''),
|
|
2173
2212
|
children: submitText
|
|
2174
2213
|
}))
|
|
2175
2214
|
});
|
|
@@ -2453,16 +2492,16 @@ function ObjectFieldTemplate(props) {
|
|
|
2453
2492
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2454
2493
|
return jsxs("fieldset", {
|
|
2455
2494
|
id: idSchema.$id,
|
|
2456
|
-
children: [
|
|
2495
|
+
children: [title && jsx(TitleFieldTemplate, {
|
|
2457
2496
|
id: titleId(idSchema),
|
|
2458
|
-
title:
|
|
2497
|
+
title: title,
|
|
2459
2498
|
required: required,
|
|
2460
2499
|
schema: schema,
|
|
2461
2500
|
uiSchema: uiSchema,
|
|
2462
2501
|
registry: registry
|
|
2463
|
-
}),
|
|
2502
|
+
}), description && jsx(DescriptionFieldTemplate, {
|
|
2464
2503
|
id: descriptionId(idSchema),
|
|
2465
|
-
description:
|
|
2504
|
+
description: description,
|
|
2466
2505
|
schema: schema,
|
|
2467
2506
|
uiSchema: uiSchema,
|
|
2468
2507
|
registry: registry
|
|
@@ -2838,6 +2877,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2838
2877
|
* @param props - The `WidgetProps` for this component
|
|
2839
2878
|
*/
|
|
2840
2879
|
function CheckboxWidget(_ref) {
|
|
2880
|
+
var _options$description;
|
|
2841
2881
|
var schema = _ref.schema,
|
|
2842
2882
|
uiSchema = _ref.uiSchema,
|
|
2843
2883
|
options = _ref.options,
|
|
@@ -2846,6 +2886,7 @@ function CheckboxWidget(_ref) {
|
|
|
2846
2886
|
disabled = _ref.disabled,
|
|
2847
2887
|
readonly = _ref.readonly,
|
|
2848
2888
|
label = _ref.label,
|
|
2889
|
+
hideLabel = _ref.hideLabel,
|
|
2849
2890
|
_ref$autofocus = _ref.autofocus,
|
|
2850
2891
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2851
2892
|
onBlur = _ref.onBlur,
|
|
@@ -2866,11 +2907,12 @@ function CheckboxWidget(_ref) {
|
|
|
2866
2907
|
var handleFocus = useCallback(function (event) {
|
|
2867
2908
|
return onFocus(id, event.target.checked);
|
|
2868
2909
|
}, [onFocus, id]);
|
|
2910
|
+
var description = (_options$description = options.description) != null ? _options$description : schema.description;
|
|
2869
2911
|
return jsxs("div", {
|
|
2870
2912
|
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2871
|
-
children: [
|
|
2913
|
+
children: [!hideLabel && !!description && jsx(DescriptionFieldTemplate, {
|
|
2872
2914
|
id: descriptionId(id),
|
|
2873
|
-
description:
|
|
2915
|
+
description: description,
|
|
2874
2916
|
schema: schema,
|
|
2875
2917
|
uiSchema: uiSchema,
|
|
2876
2918
|
registry: registry
|
|
@@ -2887,9 +2929,9 @@ function CheckboxWidget(_ref) {
|
|
|
2887
2929
|
onBlur: handleBlur,
|
|
2888
2930
|
onFocus: handleFocus,
|
|
2889
2931
|
"aria-describedby": ariaDescribedByIds(id)
|
|
2890
|
-
}), jsx("span", {
|
|
2932
|
+
}), labelValue(jsx("span", {
|
|
2891
2933
|
children: label
|
|
2892
|
-
})]
|
|
2934
|
+
}), hideLabel)]
|
|
2893
2935
|
})]
|
|
2894
2936
|
});
|
|
2895
2937
|
}
|
|
@@ -3077,9 +3119,38 @@ function processFile(file) {
|
|
|
3077
3119
|
function processFiles(files) {
|
|
3078
3120
|
return Promise.all(Array.from(files).map(processFile));
|
|
3079
3121
|
}
|
|
3080
|
-
function
|
|
3081
|
-
var
|
|
3122
|
+
function FileInfoPreview(_ref) {
|
|
3123
|
+
var fileInfo = _ref.fileInfo,
|
|
3082
3124
|
registry = _ref.registry;
|
|
3125
|
+
var translateString = registry.translateString;
|
|
3126
|
+
var dataURL = fileInfo.dataURL,
|
|
3127
|
+
type = fileInfo.type,
|
|
3128
|
+
name = fileInfo.name;
|
|
3129
|
+
if (!dataURL) {
|
|
3130
|
+
return null;
|
|
3131
|
+
}
|
|
3132
|
+
if (type.indexOf('image') !== -1) {
|
|
3133
|
+
return jsx("img", {
|
|
3134
|
+
src: dataURL,
|
|
3135
|
+
style: {
|
|
3136
|
+
maxWidth: '100%'
|
|
3137
|
+
},
|
|
3138
|
+
className: 'file-preview'
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
return jsxs(Fragment, {
|
|
3142
|
+
children: [' ', jsx("a", {
|
|
3143
|
+
download: "preview-" + name,
|
|
3144
|
+
href: dataURL,
|
|
3145
|
+
className: 'file-download',
|
|
3146
|
+
children: translateString(TranslatableString.PreviewLabel)
|
|
3147
|
+
})]
|
|
3148
|
+
});
|
|
3149
|
+
}
|
|
3150
|
+
function FilesInfo(_ref2) {
|
|
3151
|
+
var filesInfo = _ref2.filesInfo,
|
|
3152
|
+
registry = _ref2.registry,
|
|
3153
|
+
preview = _ref2.preview;
|
|
3083
3154
|
if (filesInfo.length === 0) {
|
|
3084
3155
|
return null;
|
|
3085
3156
|
}
|
|
@@ -3090,10 +3161,13 @@ function FilesInfo(_ref) {
|
|
|
3090
3161
|
var name = fileInfo.name,
|
|
3091
3162
|
size = fileInfo.size,
|
|
3092
3163
|
type = fileInfo.type;
|
|
3093
|
-
return
|
|
3094
|
-
children: jsx(Markdown, {
|
|
3164
|
+
return jsxs("li", {
|
|
3165
|
+
children: [jsx(Markdown, {
|
|
3095
3166
|
children: translateString(TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3096
|
-
})
|
|
3167
|
+
}), preview && jsx(FileInfoPreview, {
|
|
3168
|
+
fileInfo: fileInfo,
|
|
3169
|
+
registry: registry
|
|
3170
|
+
})]
|
|
3097
3171
|
}, key);
|
|
3098
3172
|
})
|
|
3099
3173
|
});
|
|
@@ -3106,6 +3180,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3106
3180
|
blob = _dataURItoBlob.blob,
|
|
3107
3181
|
name = _dataURItoBlob.name;
|
|
3108
3182
|
return {
|
|
3183
|
+
dataURL: dataURL,
|
|
3109
3184
|
name: name,
|
|
3110
3185
|
size: blob.size,
|
|
3111
3186
|
type: blob.type
|
|
@@ -3119,6 +3194,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3119
3194
|
function FileWidget(props) {
|
|
3120
3195
|
var disabled = props.disabled,
|
|
3121
3196
|
readonly = props.readonly,
|
|
3197
|
+
required = props.required,
|
|
3122
3198
|
multiple = props.multiple,
|
|
3123
3199
|
onChange = props.onChange,
|
|
3124
3200
|
value = props.value,
|
|
@@ -3151,12 +3227,14 @@ function FileWidget(props) {
|
|
|
3151
3227
|
children: [jsx(BaseInputTemplate, _extends({}, props, {
|
|
3152
3228
|
disabled: disabled || readonly,
|
|
3153
3229
|
type: 'file',
|
|
3230
|
+
required: value ? false : required,
|
|
3154
3231
|
onChangeOverride: handleChange,
|
|
3155
3232
|
value: '',
|
|
3156
3233
|
accept: options.accept ? String(options.accept) : undefined
|
|
3157
3234
|
})), jsx(FilesInfo, {
|
|
3158
3235
|
filesInfo: filesInfo,
|
|
3159
|
-
registry: registry
|
|
3236
|
+
registry: registry,
|
|
3237
|
+
preview: options.filePreview
|
|
3160
3238
|
})]
|
|
3161
3239
|
});
|
|
3162
3240
|
}
|
|
@@ -3207,8 +3285,6 @@ function RadioWidget(_ref) {
|
|
|
3207
3285
|
onFocus = _ref.onFocus,
|
|
3208
3286
|
onChange = _ref.onChange,
|
|
3209
3287
|
id = _ref.id;
|
|
3210
|
-
// Generating a unique field name to identify this set of radio buttons
|
|
3211
|
-
var name = Math.random().toString();
|
|
3212
3288
|
var enumOptions = options.enumOptions,
|
|
3213
3289
|
enumDisabled = options.enumDisabled,
|
|
3214
3290
|
inline = options.inline,
|
|
@@ -3236,7 +3312,7 @@ function RadioWidget(_ref) {
|
|
|
3236
3312
|
type: 'radio',
|
|
3237
3313
|
id: optionId(id, i),
|
|
3238
3314
|
checked: checked,
|
|
3239
|
-
name:
|
|
3315
|
+
name: id,
|
|
3240
3316
|
required: required,
|
|
3241
3317
|
value: String(i),
|
|
3242
3318
|
disabled: disabled || itemDisabled || readonly,
|
|
@@ -3919,6 +3995,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3919
3995
|
// if not an exact match, try finding an input starting with the element id (like radio buttons or checkboxes)
|
|
3920
3996
|
field = this.formElement.current.querySelector("input[id^=" + elementId);
|
|
3921
3997
|
}
|
|
3998
|
+
if (field.length) {
|
|
3999
|
+
// If we got a list with length > 0
|
|
4000
|
+
field = field[0];
|
|
4001
|
+
}
|
|
3922
4002
|
if (field) {
|
|
3923
4003
|
field.focus();
|
|
3924
4004
|
}
|