@rjsf/core 5.3.1 → 5.4.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 +124 -49
- 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 +125 -50
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +124 -49
- 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 +9 -7
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
return typeof key === "symbol" ? key : String(key);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
var _excluded$9 = ["widget"],
|
|
92
|
-
_excluded2 = ["widget"],
|
|
93
|
-
_excluded3 = ["widget"];
|
|
91
|
+
var _excluded$9 = ["widget", "title"],
|
|
92
|
+
_excluded2 = ["widget", "title"],
|
|
93
|
+
_excluded3 = ["widget", "title"];
|
|
94
94
|
/** Used to generate a unique ID for an element in a row */
|
|
95
95
|
function generateRowId() {
|
|
96
96
|
return nanoid.nanoid();
|
|
@@ -511,6 +511,7 @@
|
|
|
511
511
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
512
512
|
*/;
|
|
513
513
|
_proto.renderCustomWidget = function renderCustomWidget() {
|
|
514
|
+
var _ref;
|
|
514
515
|
var _this$props9 = this.props,
|
|
515
516
|
schema = _this$props9.schema,
|
|
516
517
|
idSchema = _this$props9.idSchema,
|
|
@@ -533,12 +534,16 @@
|
|
|
533
534
|
rawErrors = _this$props9.rawErrors,
|
|
534
535
|
name = _this$props9.name;
|
|
535
536
|
var widgets = registry.widgets,
|
|
536
|
-
formContext = registry.formContext
|
|
537
|
-
|
|
538
|
-
|
|
537
|
+
formContext = registry.formContext,
|
|
538
|
+
globalUiOptions = registry.globalUiOptions,
|
|
539
|
+
schemaUtils = registry.schemaUtils;
|
|
540
|
+
var _getUiOptions2 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
539
541
|
widget = _getUiOptions2.widget,
|
|
542
|
+
uiTitle = _getUiOptions2.title,
|
|
540
543
|
options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
|
|
541
544
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
545
|
+
var label = (_ref = uiTitle != null ? uiTitle : schema.title) != null ? _ref : name;
|
|
546
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
542
547
|
return jsxRuntime.jsx(Widget, {
|
|
543
548
|
id: idSchema.$id,
|
|
544
549
|
name: name,
|
|
@@ -555,7 +560,8 @@
|
|
|
555
560
|
readonly: readonly,
|
|
556
561
|
hideError: hideError,
|
|
557
562
|
required: required,
|
|
558
|
-
label:
|
|
563
|
+
label: label,
|
|
564
|
+
hideLabel: !displayLabel,
|
|
559
565
|
placeholder: placeholder,
|
|
560
566
|
formContext: formContext,
|
|
561
567
|
autofocus: autofocus,
|
|
@@ -565,6 +571,7 @@
|
|
|
565
571
|
/** Renders an array as a set of checkboxes
|
|
566
572
|
*/;
|
|
567
573
|
_proto.renderMultiSelect = function renderMultiSelect() {
|
|
574
|
+
var _ref2;
|
|
568
575
|
var _this$props10 = this.props,
|
|
569
576
|
schema = _this$props10.schema,
|
|
570
577
|
idSchema = _this$props10.idSchema,
|
|
@@ -587,15 +594,18 @@
|
|
|
587
594
|
name = _this$props10.name;
|
|
588
595
|
var widgets = registry.widgets,
|
|
589
596
|
schemaUtils = registry.schemaUtils,
|
|
590
|
-
formContext = registry.formContext
|
|
597
|
+
formContext = registry.formContext,
|
|
598
|
+
globalUiOptions = registry.globalUiOptions;
|
|
591
599
|
var itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
592
|
-
var title = schema.title || name;
|
|
593
600
|
var enumOptions = utils.optionsList(itemsSchema);
|
|
594
|
-
var _getUiOptions3 = utils.getUiOptions(uiSchema),
|
|
601
|
+
var _getUiOptions3 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
595
602
|
_getUiOptions3$widget = _getUiOptions3.widget,
|
|
596
603
|
widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
|
|
604
|
+
uiTitle = _getUiOptions3.title,
|
|
597
605
|
options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
|
|
598
606
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
607
|
+
var label = (_ref2 = uiTitle != null ? uiTitle : schema.title) != null ? _ref2 : name;
|
|
608
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
599
609
|
return jsxRuntime.jsx(Widget, {
|
|
600
610
|
id: idSchema.$id,
|
|
601
611
|
name: name,
|
|
@@ -613,7 +623,8 @@
|
|
|
613
623
|
disabled: disabled,
|
|
614
624
|
readonly: readonly,
|
|
615
625
|
required: required,
|
|
616
|
-
label:
|
|
626
|
+
label: label,
|
|
627
|
+
hideLabel: !displayLabel,
|
|
617
628
|
placeholder: placeholder,
|
|
618
629
|
formContext: formContext,
|
|
619
630
|
autofocus: autofocus,
|
|
@@ -623,6 +634,7 @@
|
|
|
623
634
|
/** Renders an array of files using the `FileWidget`
|
|
624
635
|
*/;
|
|
625
636
|
_proto.renderFiles = function renderFiles() {
|
|
637
|
+
var _ref3;
|
|
626
638
|
var _this$props11 = this.props,
|
|
627
639
|
schema = _this$props11.schema,
|
|
628
640
|
uiSchema = _this$props11.uiSchema,
|
|
@@ -642,14 +654,18 @@
|
|
|
642
654
|
_this$props11$formDat = _this$props11.formData,
|
|
643
655
|
items = _this$props11$formDat === void 0 ? [] : _this$props11$formDat,
|
|
644
656
|
rawErrors = _this$props11.rawErrors;
|
|
645
|
-
var title = schema.title || name;
|
|
646
657
|
var widgets = registry.widgets,
|
|
647
|
-
formContext = registry.formContext
|
|
648
|
-
|
|
658
|
+
formContext = registry.formContext,
|
|
659
|
+
globalUiOptions = registry.globalUiOptions,
|
|
660
|
+
schemaUtils = registry.schemaUtils;
|
|
661
|
+
var _getUiOptions4 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
649
662
|
_getUiOptions4$widget = _getUiOptions4.widget,
|
|
650
663
|
widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
|
|
664
|
+
uiTitle = _getUiOptions4.title,
|
|
651
665
|
options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
|
|
652
666
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
667
|
+
var label = (_ref3 = uiTitle != null ? uiTitle : schema.title) != null ? _ref3 : name;
|
|
668
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
653
669
|
return jsxRuntime.jsx(Widget, {
|
|
654
670
|
options: options,
|
|
655
671
|
id: idSchema.$id,
|
|
@@ -660,7 +676,6 @@
|
|
|
660
676
|
onFocus: onFocus,
|
|
661
677
|
schema: schema,
|
|
662
678
|
uiSchema: uiSchema,
|
|
663
|
-
title: title,
|
|
664
679
|
value: items,
|
|
665
680
|
disabled: disabled,
|
|
666
681
|
readonly: readonly,
|
|
@@ -669,7 +684,8 @@
|
|
|
669
684
|
formContext: formContext,
|
|
670
685
|
autofocus: autofocus,
|
|
671
686
|
rawErrors: rawErrors,
|
|
672
|
-
label:
|
|
687
|
+
label: label,
|
|
688
|
+
hideLabel: !displayLabel
|
|
673
689
|
});
|
|
674
690
|
}
|
|
675
691
|
/** Renders an array that has a maximum limit of items
|
|
@@ -881,13 +897,14 @@
|
|
|
881
897
|
return ArrayField;
|
|
882
898
|
}(react.Component);
|
|
883
899
|
|
|
884
|
-
var _excluded$8 = ["widget"];
|
|
900
|
+
var _excluded$8 = ["widget", "title", "label"];
|
|
885
901
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
886
902
|
* two boolean values based on the various alternatives in the schema.
|
|
887
903
|
*
|
|
888
904
|
* @param props - The `FieldProps` for this template
|
|
889
905
|
*/
|
|
890
906
|
function BooleanField(props) {
|
|
907
|
+
var _ref;
|
|
891
908
|
var schema = props.schema,
|
|
892
909
|
name = props.name,
|
|
893
910
|
uiSchema = props.uiSchema,
|
|
@@ -905,15 +922,20 @@
|
|
|
905
922
|
var title = schema.title;
|
|
906
923
|
var widgets = registry.widgets,
|
|
907
924
|
formContext = registry.formContext,
|
|
908
|
-
translateString = registry.translateString
|
|
909
|
-
|
|
925
|
+
translateString = registry.translateString,
|
|
926
|
+
globalUiOptions = registry.globalUiOptions;
|
|
927
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
910
928
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
911
929
|
widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
|
|
930
|
+
uiTitle = _getUiOptions.title,
|
|
931
|
+
_getUiOptions$label = _getUiOptions.label,
|
|
932
|
+
displayLabel = _getUiOptions$label === void 0 ? true : _getUiOptions$label,
|
|
912
933
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
913
934
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
914
935
|
var yes = translateString(utils.TranslatableString.YesLabel);
|
|
915
936
|
var no = translateString(utils.TranslatableString.NoLabel);
|
|
916
937
|
var enumOptions;
|
|
938
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
917
939
|
if (Array.isArray(schema.oneOf)) {
|
|
918
940
|
enumOptions = utils.optionsList({
|
|
919
941
|
oneOf: schema.oneOf.map(function (option) {
|
|
@@ -961,7 +983,8 @@
|
|
|
961
983
|
onChange: onChange,
|
|
962
984
|
onFocus: onFocus,
|
|
963
985
|
onBlur: onBlur,
|
|
964
|
-
label:
|
|
986
|
+
label: label,
|
|
987
|
+
hideLabel: !displayLabel,
|
|
965
988
|
value: formData,
|
|
966
989
|
required: required,
|
|
967
990
|
disabled: disabled,
|
|
@@ -1114,12 +1137,14 @@
|
|
|
1114
1137
|
uiSchema = _this$props5.uiSchema;
|
|
1115
1138
|
var widgets = registry.widgets,
|
|
1116
1139
|
fields = registry.fields,
|
|
1117
|
-
translateString = registry.translateString
|
|
1140
|
+
translateString = registry.translateString,
|
|
1141
|
+
globalUiOptions = registry.globalUiOptions,
|
|
1142
|
+
schemaUtils = registry.schemaUtils;
|
|
1118
1143
|
var _SchemaField = fields.SchemaField;
|
|
1119
1144
|
var _this$state2 = this.state,
|
|
1120
1145
|
selectedOption = _this$state2.selectedOption,
|
|
1121
1146
|
retrievedOptions = _this$state2.retrievedOptions;
|
|
1122
|
-
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
1147
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
1123
1148
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
1124
1149
|
widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
|
|
1125
1150
|
placeholder = _getUiOptions.placeholder,
|
|
@@ -1133,6 +1158,7 @@
|
|
|
1133
1158
|
}, widget, widgets);
|
|
1134
1159
|
var rawErrors = get__default["default"](errorSchema, utils.ERRORS_KEY, []);
|
|
1135
1160
|
var fieldErrorSchema = omit__default["default"](errorSchema, [utils.ERRORS_KEY]);
|
|
1161
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1136
1162
|
var option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1137
1163
|
var optionSchema;
|
|
1138
1164
|
if (option) {
|
|
@@ -1177,7 +1203,8 @@
|
|
|
1177
1203
|
placeholder: placeholder,
|
|
1178
1204
|
autocomplete: autocomplete,
|
|
1179
1205
|
autofocus: autofocus,
|
|
1180
|
-
label:
|
|
1206
|
+
label: title != null ? title : name,
|
|
1207
|
+
hideLabel: !displayLabel
|
|
1181
1208
|
})
|
|
1182
1209
|
}), option !== null && jsxRuntime.jsx(_SchemaField, _extends({}, this.props, {
|
|
1183
1210
|
schema: optionSchema
|
|
@@ -1432,7 +1459,10 @@
|
|
|
1432
1459
|
/** Renders the `ObjectField` from the given props
|
|
1433
1460
|
*/
|
|
1434
1461
|
_proto.render = function render() {
|
|
1435
|
-
var
|
|
1462
|
+
var _ref2,
|
|
1463
|
+
_uiOptions$title,
|
|
1464
|
+
_uiOptions$descriptio,
|
|
1465
|
+
_this2 = this;
|
|
1436
1466
|
var _this$props6 = this.props,
|
|
1437
1467
|
rawSchema = _this$props6.schema,
|
|
1438
1468
|
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
@@ -1456,14 +1486,15 @@
|
|
|
1456
1486
|
var fields = registry.fields,
|
|
1457
1487
|
formContext = registry.formContext,
|
|
1458
1488
|
schemaUtils = registry.schemaUtils,
|
|
1459
|
-
translateString = registry.translateString
|
|
1489
|
+
translateString = registry.translateString,
|
|
1490
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1460
1491
|
var SchemaField = fields.SchemaField;
|
|
1461
1492
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1462
|
-
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1493
|
+
var uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1463
1494
|
var _schema$properties = schema.properties,
|
|
1464
1495
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1465
|
-
var title =
|
|
1466
|
-
var description = uiOptions.description
|
|
1496
|
+
var title = (_ref2 = (_uiOptions$title = uiOptions.title) != null ? _uiOptions$title : schema.title) != null ? _ref2 : name;
|
|
1497
|
+
var description = (_uiOptions$descriptio = uiOptions.description) != null ? _uiOptions$descriptio : schema.description;
|
|
1467
1498
|
var orderedProperties;
|
|
1468
1499
|
try {
|
|
1469
1500
|
var properties = Object.keys(schemaProperties);
|
|
@@ -1485,8 +1516,9 @@
|
|
|
1485
1516
|
}
|
|
1486
1517
|
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1487
1518
|
var templateProps = {
|
|
1488
|
-
|
|
1489
|
-
|
|
1519
|
+
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
1520
|
+
title: uiOptions.label === false ? '' : title,
|
|
1521
|
+
description: uiOptions.label === false ? undefined : description,
|
|
1490
1522
|
properties: orderedProperties.map(function (name) {
|
|
1491
1523
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
1492
1524
|
var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
@@ -1803,12 +1835,13 @@
|
|
|
1803
1835
|
return SchemaField;
|
|
1804
1836
|
}(react.Component);
|
|
1805
1837
|
|
|
1806
|
-
var _excluded$5 = ["widget", "placeholder"];
|
|
1838
|
+
var _excluded$5 = ["widget", "placeholder", "title"];
|
|
1807
1839
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
1808
1840
|
*
|
|
1809
1841
|
* @param props - The `FieldProps` for this template
|
|
1810
1842
|
*/
|
|
1811
1843
|
function StringField(props) {
|
|
1844
|
+
var _ref;
|
|
1812
1845
|
var schema = props.schema,
|
|
1813
1846
|
name = props.name,
|
|
1814
1847
|
uiSchema = props.uiSchema,
|
|
@@ -1830,7 +1863,8 @@
|
|
|
1830
1863
|
format = schema.format;
|
|
1831
1864
|
var widgets = registry.widgets,
|
|
1832
1865
|
formContext = registry.formContext,
|
|
1833
|
-
schemaUtils = registry.schemaUtils
|
|
1866
|
+
schemaUtils = registry.schemaUtils,
|
|
1867
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1834
1868
|
var enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : undefined;
|
|
1835
1869
|
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1836
1870
|
if (format && utils.hasWidget(schema, format, widgets)) {
|
|
@@ -1841,7 +1875,10 @@
|
|
|
1841
1875
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1842
1876
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1843
1877
|
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1878
|
+
uiTitle = _getUiOptions.title,
|
|
1844
1879
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1880
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1881
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
1845
1882
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
1846
1883
|
return jsxRuntime.jsx(Widget, {
|
|
1847
1884
|
options: _extends({}, options, {
|
|
@@ -1851,7 +1888,8 @@
|
|
|
1851
1888
|
uiSchema: uiSchema,
|
|
1852
1889
|
id: idSchema.$id,
|
|
1853
1890
|
name: name,
|
|
1854
|
-
label:
|
|
1891
|
+
label: label,
|
|
1892
|
+
hideLabel: !displayLabel,
|
|
1855
1893
|
value: formData,
|
|
1856
1894
|
onChange: onChange,
|
|
1857
1895
|
onBlur: onBlur,
|
|
@@ -1909,7 +1947,7 @@
|
|
|
1909
1947
|
registry = props.registry,
|
|
1910
1948
|
schema = props.schema,
|
|
1911
1949
|
uiSchema = props.uiSchema;
|
|
1912
|
-
var options = utils.getUiOptions(uiSchema);
|
|
1950
|
+
var options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
|
|
1913
1951
|
var _options$label = options.label,
|
|
1914
1952
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
1915
1953
|
if (!description || !displayLabel) {
|
|
@@ -2068,7 +2106,7 @@
|
|
|
2068
2106
|
uiSchema = props.uiSchema,
|
|
2069
2107
|
required = props.required,
|
|
2070
2108
|
registry = props.registry;
|
|
2071
|
-
var options = utils.getUiOptions(uiSchema);
|
|
2109
|
+
var options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
|
|
2072
2110
|
var _options$label = options.label,
|
|
2073
2111
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
2074
2112
|
if (!title || !displayLabel) {
|
|
@@ -2457,16 +2495,16 @@
|
|
|
2457
2495
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2458
2496
|
return jsxRuntime.jsxs("fieldset", {
|
|
2459
2497
|
id: idSchema.$id,
|
|
2460
|
-
children: [
|
|
2498
|
+
children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2461
2499
|
id: utils.titleId(idSchema),
|
|
2462
|
-
title:
|
|
2500
|
+
title: title,
|
|
2463
2501
|
required: required,
|
|
2464
2502
|
schema: schema,
|
|
2465
2503
|
uiSchema: uiSchema,
|
|
2466
2504
|
registry: registry
|
|
2467
|
-
}),
|
|
2505
|
+
}), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2468
2506
|
id: utils.descriptionId(idSchema),
|
|
2469
|
-
description:
|
|
2507
|
+
description: description,
|
|
2470
2508
|
schema: schema,
|
|
2471
2509
|
uiSchema: uiSchema,
|
|
2472
2510
|
registry: registry
|
|
@@ -2842,6 +2880,7 @@
|
|
|
2842
2880
|
* @param props - The `WidgetProps` for this component
|
|
2843
2881
|
*/
|
|
2844
2882
|
function CheckboxWidget(_ref) {
|
|
2883
|
+
var _options$description;
|
|
2845
2884
|
var schema = _ref.schema,
|
|
2846
2885
|
uiSchema = _ref.uiSchema,
|
|
2847
2886
|
options = _ref.options,
|
|
@@ -2850,6 +2889,7 @@
|
|
|
2850
2889
|
disabled = _ref.disabled,
|
|
2851
2890
|
readonly = _ref.readonly,
|
|
2852
2891
|
label = _ref.label,
|
|
2892
|
+
hideLabel = _ref.hideLabel,
|
|
2853
2893
|
_ref$autofocus = _ref.autofocus,
|
|
2854
2894
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2855
2895
|
onBlur = _ref.onBlur,
|
|
@@ -2870,11 +2910,12 @@
|
|
|
2870
2910
|
var handleFocus = react.useCallback(function (event) {
|
|
2871
2911
|
return onFocus(id, event.target.checked);
|
|
2872
2912
|
}, [onFocus, id]);
|
|
2913
|
+
var description = (_options$description = options.description) != null ? _options$description : schema.description;
|
|
2873
2914
|
return jsxRuntime.jsxs("div", {
|
|
2874
2915
|
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2875
|
-
children: [
|
|
2916
|
+
children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2876
2917
|
id: utils.descriptionId(id),
|
|
2877
|
-
description:
|
|
2918
|
+
description: description,
|
|
2878
2919
|
schema: schema,
|
|
2879
2920
|
uiSchema: uiSchema,
|
|
2880
2921
|
registry: registry
|
|
@@ -2891,9 +2932,9 @@
|
|
|
2891
2932
|
onBlur: handleBlur,
|
|
2892
2933
|
onFocus: handleFocus,
|
|
2893
2934
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2894
|
-
}), jsxRuntime.jsx("span", {
|
|
2935
|
+
}), utils.labelValue(jsxRuntime.jsx("span", {
|
|
2895
2936
|
children: label
|
|
2896
|
-
})]
|
|
2937
|
+
}), hideLabel)]
|
|
2897
2938
|
})]
|
|
2898
2939
|
});
|
|
2899
2940
|
}
|
|
@@ -3081,9 +3122,38 @@
|
|
|
3081
3122
|
function processFiles(files) {
|
|
3082
3123
|
return Promise.all(Array.from(files).map(processFile));
|
|
3083
3124
|
}
|
|
3084
|
-
function
|
|
3085
|
-
var
|
|
3125
|
+
function FileInfoPreview(_ref) {
|
|
3126
|
+
var fileInfo = _ref.fileInfo,
|
|
3086
3127
|
registry = _ref.registry;
|
|
3128
|
+
var translateString = registry.translateString;
|
|
3129
|
+
var dataURL = fileInfo.dataURL,
|
|
3130
|
+
type = fileInfo.type,
|
|
3131
|
+
name = fileInfo.name;
|
|
3132
|
+
if (!dataURL) {
|
|
3133
|
+
return null;
|
|
3134
|
+
}
|
|
3135
|
+
if (type.indexOf('image') !== -1) {
|
|
3136
|
+
return jsxRuntime.jsx("img", {
|
|
3137
|
+
src: dataURL,
|
|
3138
|
+
style: {
|
|
3139
|
+
maxWidth: '100%'
|
|
3140
|
+
},
|
|
3141
|
+
className: 'file-preview'
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3145
|
+
children: [' ', jsxRuntime.jsx("a", {
|
|
3146
|
+
download: "preview-" + name,
|
|
3147
|
+
href: dataURL,
|
|
3148
|
+
className: 'file-download',
|
|
3149
|
+
children: translateString(utils.TranslatableString.PreviewLabel)
|
|
3150
|
+
})]
|
|
3151
|
+
});
|
|
3152
|
+
}
|
|
3153
|
+
function FilesInfo(_ref2) {
|
|
3154
|
+
var filesInfo = _ref2.filesInfo,
|
|
3155
|
+
registry = _ref2.registry,
|
|
3156
|
+
preview = _ref2.preview;
|
|
3087
3157
|
if (filesInfo.length === 0) {
|
|
3088
3158
|
return null;
|
|
3089
3159
|
}
|
|
@@ -3094,10 +3164,13 @@
|
|
|
3094
3164
|
var name = fileInfo.name,
|
|
3095
3165
|
size = fileInfo.size,
|
|
3096
3166
|
type = fileInfo.type;
|
|
3097
|
-
return jsxRuntime.
|
|
3098
|
-
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3167
|
+
return jsxRuntime.jsxs("li", {
|
|
3168
|
+
children: [jsxRuntime.jsx(Markdown__default["default"], {
|
|
3099
3169
|
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3100
|
-
})
|
|
3170
|
+
}), preview && jsxRuntime.jsx(FileInfoPreview, {
|
|
3171
|
+
fileInfo: fileInfo,
|
|
3172
|
+
registry: registry
|
|
3173
|
+
})]
|
|
3101
3174
|
}, key);
|
|
3102
3175
|
})
|
|
3103
3176
|
});
|
|
@@ -3110,6 +3183,7 @@
|
|
|
3110
3183
|
blob = _dataURItoBlob.blob,
|
|
3111
3184
|
name = _dataURItoBlob.name;
|
|
3112
3185
|
return {
|
|
3186
|
+
dataURL: dataURL,
|
|
3113
3187
|
name: name,
|
|
3114
3188
|
size: blob.size,
|
|
3115
3189
|
type: blob.type
|
|
@@ -3160,7 +3234,8 @@
|
|
|
3160
3234
|
accept: options.accept ? String(options.accept) : undefined
|
|
3161
3235
|
})), jsxRuntime.jsx(FilesInfo, {
|
|
3162
3236
|
filesInfo: filesInfo,
|
|
3163
|
-
registry: registry
|
|
3237
|
+
registry: registry,
|
|
3238
|
+
preview: options.filePreview
|
|
3164
3239
|
})]
|
|
3165
3240
|
});
|
|
3166
3241
|
}
|