@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
|
@@ -102,9 +102,9 @@ function _toPropertyKey(arg) {
|
|
|
102
102
|
return typeof key === "symbol" ? key : String(key);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
var _excluded$9 = ["widget"],
|
|
106
|
-
_excluded2 = ["widget"],
|
|
107
|
-
_excluded3 = ["widget"];
|
|
105
|
+
var _excluded$9 = ["widget", "title"],
|
|
106
|
+
_excluded2 = ["widget", "title"],
|
|
107
|
+
_excluded3 = ["widget", "title"];
|
|
108
108
|
/** Used to generate a unique ID for an element in a row */
|
|
109
109
|
function generateRowId() {
|
|
110
110
|
return nanoid.nanoid();
|
|
@@ -525,6 +525,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
525
525
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
526
526
|
*/;
|
|
527
527
|
_proto.renderCustomWidget = function renderCustomWidget() {
|
|
528
|
+
var _ref;
|
|
528
529
|
var _this$props9 = this.props,
|
|
529
530
|
schema = _this$props9.schema,
|
|
530
531
|
idSchema = _this$props9.idSchema,
|
|
@@ -547,12 +548,16 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
547
548
|
rawErrors = _this$props9.rawErrors,
|
|
548
549
|
name = _this$props9.name;
|
|
549
550
|
var widgets = registry.widgets,
|
|
550
|
-
formContext = registry.formContext
|
|
551
|
-
|
|
552
|
-
|
|
551
|
+
formContext = registry.formContext,
|
|
552
|
+
globalUiOptions = registry.globalUiOptions,
|
|
553
|
+
schemaUtils = registry.schemaUtils;
|
|
554
|
+
var _getUiOptions2 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
553
555
|
widget = _getUiOptions2.widget,
|
|
556
|
+
uiTitle = _getUiOptions2.title,
|
|
554
557
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
555
558
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
559
|
+
var label = (_ref = uiTitle != null ? uiTitle : schema.title) != null ? _ref : name;
|
|
560
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
556
561
|
return jsxRuntime.jsx(Widget, {
|
|
557
562
|
id: idSchema.$id,
|
|
558
563
|
name: name,
|
|
@@ -569,7 +574,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
569
574
|
readonly: readonly,
|
|
570
575
|
hideError: hideError,
|
|
571
576
|
required: required,
|
|
572
|
-
label:
|
|
577
|
+
label: label,
|
|
578
|
+
hideLabel: !displayLabel,
|
|
573
579
|
placeholder: placeholder,
|
|
574
580
|
formContext: formContext,
|
|
575
581
|
autofocus: autofocus,
|
|
@@ -579,6 +585,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
579
585
|
/** Renders an array as a set of checkboxes
|
|
580
586
|
*/;
|
|
581
587
|
_proto.renderMultiSelect = function renderMultiSelect() {
|
|
588
|
+
var _ref2;
|
|
582
589
|
var _this$props10 = this.props,
|
|
583
590
|
schema = _this$props10.schema,
|
|
584
591
|
idSchema = _this$props10.idSchema,
|
|
@@ -601,15 +608,18 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
601
608
|
name = _this$props10.name;
|
|
602
609
|
var widgets = registry.widgets,
|
|
603
610
|
schemaUtils = registry.schemaUtils,
|
|
604
|
-
formContext = registry.formContext
|
|
611
|
+
formContext = registry.formContext,
|
|
612
|
+
globalUiOptions = registry.globalUiOptions;
|
|
605
613
|
var itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
606
|
-
var title = schema.title || name;
|
|
607
614
|
var enumOptions = utils.optionsList(itemsSchema);
|
|
608
|
-
var _getUiOptions3 = utils.getUiOptions(uiSchema),
|
|
615
|
+
var _getUiOptions3 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
609
616
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
610
617
|
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
618
|
+
uiTitle = _getUiOptions3.title,
|
|
611
619
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
612
620
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
621
|
+
var label = (_ref2 = uiTitle != null ? uiTitle : schema.title) != null ? _ref2 : name;
|
|
622
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
613
623
|
return jsxRuntime.jsx(Widget, {
|
|
614
624
|
id: idSchema.$id,
|
|
615
625
|
name: name,
|
|
@@ -627,7 +637,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
627
637
|
disabled: disabled,
|
|
628
638
|
readonly: readonly,
|
|
629
639
|
required: required,
|
|
630
|
-
label:
|
|
640
|
+
label: label,
|
|
641
|
+
hideLabel: !displayLabel,
|
|
631
642
|
placeholder: placeholder,
|
|
632
643
|
formContext: formContext,
|
|
633
644
|
autofocus: autofocus,
|
|
@@ -637,6 +648,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
637
648
|
/** Renders an array of files using the `FileWidget`
|
|
638
649
|
*/;
|
|
639
650
|
_proto.renderFiles = function renderFiles() {
|
|
651
|
+
var _ref3;
|
|
640
652
|
var _this$props11 = this.props,
|
|
641
653
|
schema = _this$props11.schema,
|
|
642
654
|
uiSchema = _this$props11.uiSchema,
|
|
@@ -656,14 +668,18 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
656
668
|
_this$props11$formDat = _this$props11.formData,
|
|
657
669
|
items = _this$props11$formDat === void 0 ? [] : _this$props11$formDat,
|
|
658
670
|
rawErrors = _this$props11.rawErrors;
|
|
659
|
-
var title = schema.title || name;
|
|
660
671
|
var widgets = registry.widgets,
|
|
661
|
-
formContext = registry.formContext
|
|
662
|
-
|
|
672
|
+
formContext = registry.formContext,
|
|
673
|
+
globalUiOptions = registry.globalUiOptions,
|
|
674
|
+
schemaUtils = registry.schemaUtils;
|
|
675
|
+
var _getUiOptions4 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
663
676
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
664
677
|
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
678
|
+
uiTitle = _getUiOptions4.title,
|
|
665
679
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
666
680
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
681
|
+
var label = (_ref3 = uiTitle != null ? uiTitle : schema.title) != null ? _ref3 : name;
|
|
682
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
667
683
|
return jsxRuntime.jsx(Widget, {
|
|
668
684
|
options: options,
|
|
669
685
|
id: idSchema.$id,
|
|
@@ -674,7 +690,6 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
674
690
|
onFocus: onFocus,
|
|
675
691
|
schema: schema,
|
|
676
692
|
uiSchema: uiSchema,
|
|
677
|
-
title: title,
|
|
678
693
|
value: items,
|
|
679
694
|
disabled: disabled,
|
|
680
695
|
readonly: readonly,
|
|
@@ -683,7 +698,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
683
698
|
formContext: formContext,
|
|
684
699
|
autofocus: autofocus,
|
|
685
700
|
rawErrors: rawErrors,
|
|
686
|
-
label:
|
|
701
|
+
label: label,
|
|
702
|
+
hideLabel: !displayLabel
|
|
687
703
|
});
|
|
688
704
|
}
|
|
689
705
|
/** Renders an array that has a maximum limit of items
|
|
@@ -895,13 +911,14 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
895
911
|
return ArrayField;
|
|
896
912
|
}(react.Component);
|
|
897
913
|
|
|
898
|
-
var _excluded$8 = ["widget"];
|
|
914
|
+
var _excluded$8 = ["widget", "title", "label"];
|
|
899
915
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
900
916
|
* two boolean values based on the various alternatives in the schema.
|
|
901
917
|
*
|
|
902
918
|
* @param props - The `FieldProps` for this template
|
|
903
919
|
*/
|
|
904
920
|
function BooleanField(props) {
|
|
921
|
+
var _ref;
|
|
905
922
|
var schema = props.schema,
|
|
906
923
|
name = props.name,
|
|
907
924
|
uiSchema = props.uiSchema,
|
|
@@ -919,15 +936,20 @@ function BooleanField(props) {
|
|
|
919
936
|
var title = schema.title;
|
|
920
937
|
var widgets = registry.widgets,
|
|
921
938
|
formContext = registry.formContext,
|
|
922
|
-
translateString = registry.translateString
|
|
923
|
-
|
|
939
|
+
translateString = registry.translateString,
|
|
940
|
+
globalUiOptions = registry.globalUiOptions;
|
|
941
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
924
942
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
925
943
|
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
944
|
+
uiTitle = _getUiOptions.title,
|
|
945
|
+
_getUiOptions$label = _getUiOptions.label,
|
|
946
|
+
displayLabel = _getUiOptions$label === void 0 ? true : _getUiOptions$label,
|
|
926
947
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
927
948
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
928
949
|
var yes = translateString(utils.TranslatableString.YesLabel);
|
|
929
950
|
var no = translateString(utils.TranslatableString.NoLabel);
|
|
930
951
|
var enumOptions;
|
|
952
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
931
953
|
if (Array.isArray(schema.oneOf)) {
|
|
932
954
|
enumOptions = utils.optionsList({
|
|
933
955
|
oneOf: schema.oneOf.map(function (option) {
|
|
@@ -975,7 +997,8 @@ function BooleanField(props) {
|
|
|
975
997
|
onChange: onChange,
|
|
976
998
|
onFocus: onFocus,
|
|
977
999
|
onBlur: onBlur,
|
|
978
|
-
label:
|
|
1000
|
+
label: label,
|
|
1001
|
+
hideLabel: !displayLabel,
|
|
979
1002
|
value: formData,
|
|
980
1003
|
required: required,
|
|
981
1004
|
disabled: disabled,
|
|
@@ -1128,12 +1151,14 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1128
1151
|
uiSchema = _this$props5.uiSchema;
|
|
1129
1152
|
var widgets = registry.widgets,
|
|
1130
1153
|
fields = registry.fields,
|
|
1131
|
-
translateString = registry.translateString
|
|
1154
|
+
translateString = registry.translateString,
|
|
1155
|
+
globalUiOptions = registry.globalUiOptions,
|
|
1156
|
+
schemaUtils = registry.schemaUtils;
|
|
1132
1157
|
var _SchemaField = fields.SchemaField;
|
|
1133
1158
|
var _this$state2 = this.state,
|
|
1134
1159
|
selectedOption = _this$state2.selectedOption,
|
|
1135
1160
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1136
|
-
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1161
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
1137
1162
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1138
1163
|
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1139
1164
|
placeholder = _getUiOptions.placeholder,
|
|
@@ -1147,6 +1172,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1147
1172
|
}, widget, widgets);
|
|
1148
1173
|
var rawErrors = get__default["default"](errorSchema, utils.ERRORS_KEY, []);
|
|
1149
1174
|
var fieldErrorSchema = omit__default["default"](errorSchema, [utils.ERRORS_KEY]);
|
|
1175
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1150
1176
|
var option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1151
1177
|
var optionSchema;
|
|
1152
1178
|
if (option) {
|
|
@@ -1191,7 +1217,8 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
|
|
|
1191
1217
|
placeholder: placeholder,
|
|
1192
1218
|
autocomplete: autocomplete,
|
|
1193
1219
|
autofocus: autofocus,
|
|
1194
|
-
label:
|
|
1220
|
+
label: title != null ? title : name,
|
|
1221
|
+
hideLabel: !displayLabel
|
|
1195
1222
|
})
|
|
1196
1223
|
}), option !== null && jsxRuntime.jsx(_SchemaField, _extends({}, this.props, {
|
|
1197
1224
|
schema: optionSchema
|
|
@@ -1446,7 +1473,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1446
1473
|
/** Renders the `ObjectField` from the given props
|
|
1447
1474
|
*/
|
|
1448
1475
|
_proto.render = function render() {
|
|
1449
|
-
var
|
|
1476
|
+
var _ref2,
|
|
1477
|
+
_uiOptions$title,
|
|
1478
|
+
_uiOptions$descriptio,
|
|
1479
|
+
_this2 = this;
|
|
1450
1480
|
var _this$props6 = this.props,
|
|
1451
1481
|
rawSchema = _this$props6.schema,
|
|
1452
1482
|
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
@@ -1470,14 +1500,15 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1470
1500
|
var fields = registry.fields,
|
|
1471
1501
|
formContext = registry.formContext,
|
|
1472
1502
|
schemaUtils = registry.schemaUtils,
|
|
1473
|
-
translateString = registry.translateString
|
|
1503
|
+
translateString = registry.translateString,
|
|
1504
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1474
1505
|
var SchemaField = fields.SchemaField;
|
|
1475
1506
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1476
|
-
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1507
|
+
var uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1477
1508
|
var _schema$properties = schema.properties,
|
|
1478
1509
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1479
|
-
var title =
|
|
1480
|
-
var description = uiOptions.description
|
|
1510
|
+
var title = (_ref2 = (_uiOptions$title = uiOptions.title) != null ? _uiOptions$title : schema.title) != null ? _ref2 : name;
|
|
1511
|
+
var description = (_uiOptions$descriptio = uiOptions.description) != null ? _uiOptions$descriptio : schema.description;
|
|
1481
1512
|
var orderedProperties;
|
|
1482
1513
|
try {
|
|
1483
1514
|
var properties = Object.keys(schemaProperties);
|
|
@@ -1499,8 +1530,9 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1499
1530
|
}
|
|
1500
1531
|
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1501
1532
|
var templateProps = {
|
|
1502
|
-
|
|
1503
|
-
|
|
1533
|
+
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
1534
|
+
title: uiOptions.label === false ? '' : title,
|
|
1535
|
+
description: uiOptions.label === false ? undefined : description,
|
|
1504
1536
|
properties: orderedProperties.map(function (name) {
|
|
1505
1537
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
1506
1538
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
@@ -1541,6 +1573,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1541
1573
|
required: required,
|
|
1542
1574
|
idSchema: idSchema,
|
|
1543
1575
|
uiSchema: uiSchema,
|
|
1576
|
+
errorSchema: errorSchema,
|
|
1544
1577
|
schema: schema,
|
|
1545
1578
|
formData: formData,
|
|
1546
1579
|
formContext: formContext,
|
|
@@ -1817,12 +1850,13 @@ var SchemaField = /*#__PURE__*/function (_Component) {
|
|
|
1817
1850
|
return SchemaField;
|
|
1818
1851
|
}(react.Component);
|
|
1819
1852
|
|
|
1820
|
-
var _excluded$5 = ["widget", "placeholder"];
|
|
1853
|
+
var _excluded$5 = ["widget", "placeholder", "title"];
|
|
1821
1854
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
1822
1855
|
*
|
|
1823
1856
|
* @param props - The `FieldProps` for this template
|
|
1824
1857
|
*/
|
|
1825
1858
|
function StringField(props) {
|
|
1859
|
+
var _ref;
|
|
1826
1860
|
var schema = props.schema,
|
|
1827
1861
|
name = props.name,
|
|
1828
1862
|
uiSchema = props.uiSchema,
|
|
@@ -1844,7 +1878,8 @@ function StringField(props) {
|
|
|
1844
1878
|
format = schema.format;
|
|
1845
1879
|
var widgets = registry.widgets,
|
|
1846
1880
|
formContext = registry.formContext,
|
|
1847
|
-
schemaUtils = registry.schemaUtils
|
|
1881
|
+
schemaUtils = registry.schemaUtils,
|
|
1882
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1848
1883
|
var enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : undefined;
|
|
1849
1884
|
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1850
1885
|
if (format && utils.hasWidget(schema, format, widgets)) {
|
|
@@ -1855,7 +1890,10 @@ function StringField(props) {
|
|
|
1855
1890
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1856
1891
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1857
1892
|
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1893
|
+
uiTitle = _getUiOptions.title,
|
|
1858
1894
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1895
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1896
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
1859
1897
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
1860
1898
|
return jsxRuntime.jsx(Widget, {
|
|
1861
1899
|
options: _extends({}, options, {
|
|
@@ -1865,7 +1903,8 @@ function StringField(props) {
|
|
|
1865
1903
|
uiSchema: uiSchema,
|
|
1866
1904
|
id: idSchema.$id,
|
|
1867
1905
|
name: name,
|
|
1868
|
-
label:
|
|
1906
|
+
label: label,
|
|
1907
|
+
hideLabel: !displayLabel,
|
|
1869
1908
|
value: formData,
|
|
1870
1909
|
onChange: onChange,
|
|
1871
1910
|
onBlur: onBlur,
|
|
@@ -1923,7 +1962,7 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1923
1962
|
registry = props.registry,
|
|
1924
1963
|
schema = props.schema,
|
|
1925
1964
|
uiSchema = props.uiSchema;
|
|
1926
|
-
var options = utils.getUiOptions(uiSchema);
|
|
1965
|
+
var options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
|
|
1927
1966
|
var _options$label = options.label,
|
|
1928
1967
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
1929
1968
|
if (!description || !displayLabel) {
|
|
@@ -2082,7 +2121,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2082
2121
|
uiSchema = props.uiSchema,
|
|
2083
2122
|
required = props.required,
|
|
2084
2123
|
registry = props.registry;
|
|
2085
|
-
var options = utils.getUiOptions(uiSchema);
|
|
2124
|
+
var options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
|
|
2086
2125
|
var _options$label = options.label,
|
|
2087
2126
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
2088
2127
|
if (!title || !displayLabel) {
|
|
@@ -2099,7 +2138,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2099
2138
|
});
|
|
2100
2139
|
}
|
|
2101
2140
|
|
|
2102
|
-
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2141
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type", "hideLabel", "hideError"];
|
|
2103
2142
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2104
2143
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2105
2144
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2187,7 +2226,7 @@ function SubmitButton(_ref) {
|
|
|
2187
2226
|
children: jsxRuntime.jsx("button", _extends({
|
|
2188
2227
|
type: 'submit'
|
|
2189
2228
|
}, submitButtonProps, {
|
|
2190
|
-
className: "btn btn-info " + submitButtonProps.className,
|
|
2229
|
+
className: "btn btn-info " + (submitButtonProps.className || ''),
|
|
2191
2230
|
children: submitText
|
|
2192
2231
|
}))
|
|
2193
2232
|
});
|
|
@@ -2471,16 +2510,16 @@ function ObjectFieldTemplate(props) {
|
|
|
2471
2510
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2472
2511
|
return jsxRuntime.jsxs("fieldset", {
|
|
2473
2512
|
id: idSchema.$id,
|
|
2474
|
-
children: [
|
|
2513
|
+
children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2475
2514
|
id: utils.titleId(idSchema),
|
|
2476
|
-
title:
|
|
2515
|
+
title: title,
|
|
2477
2516
|
required: required,
|
|
2478
2517
|
schema: schema,
|
|
2479
2518
|
uiSchema: uiSchema,
|
|
2480
2519
|
registry: registry
|
|
2481
|
-
}),
|
|
2520
|
+
}), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2482
2521
|
id: utils.descriptionId(idSchema),
|
|
2483
|
-
description:
|
|
2522
|
+
description: description,
|
|
2484
2523
|
schema: schema,
|
|
2485
2524
|
uiSchema: uiSchema,
|
|
2486
2525
|
registry: registry
|
|
@@ -2856,6 +2895,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2856
2895
|
* @param props - The `WidgetProps` for this component
|
|
2857
2896
|
*/
|
|
2858
2897
|
function CheckboxWidget(_ref) {
|
|
2898
|
+
var _options$description;
|
|
2859
2899
|
var schema = _ref.schema,
|
|
2860
2900
|
uiSchema = _ref.uiSchema,
|
|
2861
2901
|
options = _ref.options,
|
|
@@ -2864,6 +2904,7 @@ function CheckboxWidget(_ref) {
|
|
|
2864
2904
|
disabled = _ref.disabled,
|
|
2865
2905
|
readonly = _ref.readonly,
|
|
2866
2906
|
label = _ref.label,
|
|
2907
|
+
hideLabel = _ref.hideLabel,
|
|
2867
2908
|
_ref$autofocus = _ref.autofocus,
|
|
2868
2909
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2869
2910
|
onBlur = _ref.onBlur,
|
|
@@ -2884,11 +2925,12 @@ function CheckboxWidget(_ref) {
|
|
|
2884
2925
|
var handleFocus = react.useCallback(function (event) {
|
|
2885
2926
|
return onFocus(id, event.target.checked);
|
|
2886
2927
|
}, [onFocus, id]);
|
|
2928
|
+
var description = (_options$description = options.description) != null ? _options$description : schema.description;
|
|
2887
2929
|
return jsxRuntime.jsxs("div", {
|
|
2888
2930
|
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2889
|
-
children: [
|
|
2931
|
+
children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2890
2932
|
id: utils.descriptionId(id),
|
|
2891
|
-
description:
|
|
2933
|
+
description: description,
|
|
2892
2934
|
schema: schema,
|
|
2893
2935
|
uiSchema: uiSchema,
|
|
2894
2936
|
registry: registry
|
|
@@ -2905,9 +2947,9 @@ function CheckboxWidget(_ref) {
|
|
|
2905
2947
|
onBlur: handleBlur,
|
|
2906
2948
|
onFocus: handleFocus,
|
|
2907
2949
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2908
|
-
}), jsxRuntime.jsx("span", {
|
|
2950
|
+
}), utils.labelValue(jsxRuntime.jsx("span", {
|
|
2909
2951
|
children: label
|
|
2910
|
-
})]
|
|
2952
|
+
}), hideLabel)]
|
|
2911
2953
|
})]
|
|
2912
2954
|
});
|
|
2913
2955
|
}
|
|
@@ -3095,9 +3137,38 @@ function processFile(file) {
|
|
|
3095
3137
|
function processFiles(files) {
|
|
3096
3138
|
return Promise.all(Array.from(files).map(processFile));
|
|
3097
3139
|
}
|
|
3098
|
-
function
|
|
3099
|
-
var
|
|
3140
|
+
function FileInfoPreview(_ref) {
|
|
3141
|
+
var fileInfo = _ref.fileInfo,
|
|
3100
3142
|
registry = _ref.registry;
|
|
3143
|
+
var translateString = registry.translateString;
|
|
3144
|
+
var dataURL = fileInfo.dataURL,
|
|
3145
|
+
type = fileInfo.type,
|
|
3146
|
+
name = fileInfo.name;
|
|
3147
|
+
if (!dataURL) {
|
|
3148
|
+
return null;
|
|
3149
|
+
}
|
|
3150
|
+
if (type.indexOf('image') !== -1) {
|
|
3151
|
+
return jsxRuntime.jsx("img", {
|
|
3152
|
+
src: dataURL,
|
|
3153
|
+
style: {
|
|
3154
|
+
maxWidth: '100%'
|
|
3155
|
+
},
|
|
3156
|
+
className: 'file-preview'
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3160
|
+
children: [' ', jsxRuntime.jsx("a", {
|
|
3161
|
+
download: "preview-" + name,
|
|
3162
|
+
href: dataURL,
|
|
3163
|
+
className: 'file-download',
|
|
3164
|
+
children: translateString(utils.TranslatableString.PreviewLabel)
|
|
3165
|
+
})]
|
|
3166
|
+
});
|
|
3167
|
+
}
|
|
3168
|
+
function FilesInfo(_ref2) {
|
|
3169
|
+
var filesInfo = _ref2.filesInfo,
|
|
3170
|
+
registry = _ref2.registry,
|
|
3171
|
+
preview = _ref2.preview;
|
|
3101
3172
|
if (filesInfo.length === 0) {
|
|
3102
3173
|
return null;
|
|
3103
3174
|
}
|
|
@@ -3108,10 +3179,13 @@ function FilesInfo(_ref) {
|
|
|
3108
3179
|
var name = fileInfo.name,
|
|
3109
3180
|
size = fileInfo.size,
|
|
3110
3181
|
type = fileInfo.type;
|
|
3111
|
-
return jsxRuntime.
|
|
3112
|
-
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3182
|
+
return jsxRuntime.jsxs("li", {
|
|
3183
|
+
children: [jsxRuntime.jsx(Markdown__default["default"], {
|
|
3113
3184
|
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3114
|
-
})
|
|
3185
|
+
}), preview && jsxRuntime.jsx(FileInfoPreview, {
|
|
3186
|
+
fileInfo: fileInfo,
|
|
3187
|
+
registry: registry
|
|
3188
|
+
})]
|
|
3115
3189
|
}, key);
|
|
3116
3190
|
})
|
|
3117
3191
|
});
|
|
@@ -3124,6 +3198,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3124
3198
|
blob = _dataURItoBlob.blob,
|
|
3125
3199
|
name = _dataURItoBlob.name;
|
|
3126
3200
|
return {
|
|
3201
|
+
dataURL: dataURL,
|
|
3127
3202
|
name: name,
|
|
3128
3203
|
size: blob.size,
|
|
3129
3204
|
type: blob.type
|
|
@@ -3137,6 +3212,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3137
3212
|
function FileWidget(props) {
|
|
3138
3213
|
var disabled = props.disabled,
|
|
3139
3214
|
readonly = props.readonly,
|
|
3215
|
+
required = props.required,
|
|
3140
3216
|
multiple = props.multiple,
|
|
3141
3217
|
onChange = props.onChange,
|
|
3142
3218
|
value = props.value,
|
|
@@ -3169,12 +3245,14 @@ function FileWidget(props) {
|
|
|
3169
3245
|
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({}, props, {
|
|
3170
3246
|
disabled: disabled || readonly,
|
|
3171
3247
|
type: 'file',
|
|
3248
|
+
required: value ? false : required,
|
|
3172
3249
|
onChangeOverride: handleChange,
|
|
3173
3250
|
value: '',
|
|
3174
3251
|
accept: options.accept ? String(options.accept) : undefined
|
|
3175
3252
|
})), jsxRuntime.jsx(FilesInfo, {
|
|
3176
3253
|
filesInfo: filesInfo,
|
|
3177
|
-
registry: registry
|
|
3254
|
+
registry: registry,
|
|
3255
|
+
preview: options.filePreview
|
|
3178
3256
|
})]
|
|
3179
3257
|
});
|
|
3180
3258
|
}
|
|
@@ -3225,8 +3303,6 @@ function RadioWidget(_ref) {
|
|
|
3225
3303
|
onFocus = _ref.onFocus,
|
|
3226
3304
|
onChange = _ref.onChange,
|
|
3227
3305
|
id = _ref.id;
|
|
3228
|
-
// Generating a unique field name to identify this set of radio buttons
|
|
3229
|
-
var name = Math.random().toString();
|
|
3230
3306
|
var enumOptions = options.enumOptions,
|
|
3231
3307
|
enumDisabled = options.enumDisabled,
|
|
3232
3308
|
inline = options.inline,
|
|
@@ -3254,7 +3330,7 @@ function RadioWidget(_ref) {
|
|
|
3254
3330
|
type: 'radio',
|
|
3255
3331
|
id: utils.optionId(id, i),
|
|
3256
3332
|
checked: checked,
|
|
3257
|
-
name:
|
|
3333
|
+
name: id,
|
|
3258
3334
|
required: required,
|
|
3259
3335
|
value: String(i),
|
|
3260
3336
|
disabled: disabled || itemDisabled || readonly,
|
|
@@ -3937,6 +4013,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3937
4013
|
// if not an exact match, try finding an input starting with the element id (like radio buttons or checkboxes)
|
|
3938
4014
|
field = this.formElement.current.querySelector("input[id^=" + elementId);
|
|
3939
4015
|
}
|
|
4016
|
+
if (field.length) {
|
|
4017
|
+
// If we got a list with length > 0
|
|
4018
|
+
field = field[0];
|
|
4019
|
+
}
|
|
3940
4020
|
if (field) {
|
|
3941
4021
|
field.focus();
|
|
3942
4022
|
}
|