@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
|
@@ -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];
|
|
@@ -1817,12 +1849,13 @@ var SchemaField = /*#__PURE__*/function (_Component) {
|
|
|
1817
1849
|
return SchemaField;
|
|
1818
1850
|
}(react.Component);
|
|
1819
1851
|
|
|
1820
|
-
var _excluded$5 = ["widget", "placeholder"];
|
|
1852
|
+
var _excluded$5 = ["widget", "placeholder", "title"];
|
|
1821
1853
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
1822
1854
|
*
|
|
1823
1855
|
* @param props - The `FieldProps` for this template
|
|
1824
1856
|
*/
|
|
1825
1857
|
function StringField(props) {
|
|
1858
|
+
var _ref;
|
|
1826
1859
|
var schema = props.schema,
|
|
1827
1860
|
name = props.name,
|
|
1828
1861
|
uiSchema = props.uiSchema,
|
|
@@ -1844,7 +1877,8 @@ function StringField(props) {
|
|
|
1844
1877
|
format = schema.format;
|
|
1845
1878
|
var widgets = registry.widgets,
|
|
1846
1879
|
formContext = registry.formContext,
|
|
1847
|
-
schemaUtils = registry.schemaUtils
|
|
1880
|
+
schemaUtils = registry.schemaUtils,
|
|
1881
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1848
1882
|
var enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : undefined;
|
|
1849
1883
|
var defaultWidget = enumOptions ? 'select' : 'text';
|
|
1850
1884
|
if (format && utils.hasWidget(schema, format, widgets)) {
|
|
@@ -1855,7 +1889,10 @@ function StringField(props) {
|
|
|
1855
1889
|
widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
|
|
1856
1890
|
_getUiOptions$placeho = _getUiOptions.placeholder,
|
|
1857
1891
|
placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
|
|
1892
|
+
uiTitle = _getUiOptions.title,
|
|
1858
1893
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
|
|
1894
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1895
|
+
var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
|
|
1859
1896
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
1860
1897
|
return jsxRuntime.jsx(Widget, {
|
|
1861
1898
|
options: _extends({}, options, {
|
|
@@ -1865,7 +1902,8 @@ function StringField(props) {
|
|
|
1865
1902
|
uiSchema: uiSchema,
|
|
1866
1903
|
id: idSchema.$id,
|
|
1867
1904
|
name: name,
|
|
1868
|
-
label:
|
|
1905
|
+
label: label,
|
|
1906
|
+
hideLabel: !displayLabel,
|
|
1869
1907
|
value: formData,
|
|
1870
1908
|
onChange: onChange,
|
|
1871
1909
|
onBlur: onBlur,
|
|
@@ -1923,7 +1961,7 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1923
1961
|
registry = props.registry,
|
|
1924
1962
|
schema = props.schema,
|
|
1925
1963
|
uiSchema = props.uiSchema;
|
|
1926
|
-
var options = utils.getUiOptions(uiSchema);
|
|
1964
|
+
var options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
|
|
1927
1965
|
var _options$label = options.label,
|
|
1928
1966
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
1929
1967
|
if (!description || !displayLabel) {
|
|
@@ -2082,7 +2120,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2082
2120
|
uiSchema = props.uiSchema,
|
|
2083
2121
|
required = props.required,
|
|
2084
2122
|
registry = props.registry;
|
|
2085
|
-
var options = utils.getUiOptions(uiSchema);
|
|
2123
|
+
var options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
|
|
2086
2124
|
var _options$label = options.label,
|
|
2087
2125
|
displayLabel = _options$label === void 0 ? true : _options$label;
|
|
2088
2126
|
if (!title || !displayLabel) {
|
|
@@ -2471,16 +2509,16 @@ function ObjectFieldTemplate(props) {
|
|
|
2471
2509
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
2472
2510
|
return jsxRuntime.jsxs("fieldset", {
|
|
2473
2511
|
id: idSchema.$id,
|
|
2474
|
-
children: [
|
|
2512
|
+
children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
2475
2513
|
id: utils.titleId(idSchema),
|
|
2476
|
-
title:
|
|
2514
|
+
title: title,
|
|
2477
2515
|
required: required,
|
|
2478
2516
|
schema: schema,
|
|
2479
2517
|
uiSchema: uiSchema,
|
|
2480
2518
|
registry: registry
|
|
2481
|
-
}),
|
|
2519
|
+
}), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2482
2520
|
id: utils.descriptionId(idSchema),
|
|
2483
|
-
description:
|
|
2521
|
+
description: description,
|
|
2484
2522
|
schema: schema,
|
|
2485
2523
|
uiSchema: uiSchema,
|
|
2486
2524
|
registry: registry
|
|
@@ -2856,6 +2894,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2856
2894
|
* @param props - The `WidgetProps` for this component
|
|
2857
2895
|
*/
|
|
2858
2896
|
function CheckboxWidget(_ref) {
|
|
2897
|
+
var _options$description;
|
|
2859
2898
|
var schema = _ref.schema,
|
|
2860
2899
|
uiSchema = _ref.uiSchema,
|
|
2861
2900
|
options = _ref.options,
|
|
@@ -2864,6 +2903,7 @@ function CheckboxWidget(_ref) {
|
|
|
2864
2903
|
disabled = _ref.disabled,
|
|
2865
2904
|
readonly = _ref.readonly,
|
|
2866
2905
|
label = _ref.label,
|
|
2906
|
+
hideLabel = _ref.hideLabel,
|
|
2867
2907
|
_ref$autofocus = _ref.autofocus,
|
|
2868
2908
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2869
2909
|
onBlur = _ref.onBlur,
|
|
@@ -2884,11 +2924,12 @@ function CheckboxWidget(_ref) {
|
|
|
2884
2924
|
var handleFocus = react.useCallback(function (event) {
|
|
2885
2925
|
return onFocus(id, event.target.checked);
|
|
2886
2926
|
}, [onFocus, id]);
|
|
2927
|
+
var description = (_options$description = options.description) != null ? _options$description : schema.description;
|
|
2887
2928
|
return jsxRuntime.jsxs("div", {
|
|
2888
2929
|
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2889
|
-
children: [
|
|
2930
|
+
children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2890
2931
|
id: utils.descriptionId(id),
|
|
2891
|
-
description:
|
|
2932
|
+
description: description,
|
|
2892
2933
|
schema: schema,
|
|
2893
2934
|
uiSchema: uiSchema,
|
|
2894
2935
|
registry: registry
|
|
@@ -2905,9 +2946,9 @@ function CheckboxWidget(_ref) {
|
|
|
2905
2946
|
onBlur: handleBlur,
|
|
2906
2947
|
onFocus: handleFocus,
|
|
2907
2948
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2908
|
-
}), jsxRuntime.jsx("span", {
|
|
2949
|
+
}), utils.labelValue(jsxRuntime.jsx("span", {
|
|
2909
2950
|
children: label
|
|
2910
|
-
})]
|
|
2951
|
+
}), hideLabel)]
|
|
2911
2952
|
})]
|
|
2912
2953
|
});
|
|
2913
2954
|
}
|
|
@@ -3095,9 +3136,38 @@ function processFile(file) {
|
|
|
3095
3136
|
function processFiles(files) {
|
|
3096
3137
|
return Promise.all(Array.from(files).map(processFile));
|
|
3097
3138
|
}
|
|
3098
|
-
function
|
|
3099
|
-
var
|
|
3139
|
+
function FileInfoPreview(_ref) {
|
|
3140
|
+
var fileInfo = _ref.fileInfo,
|
|
3100
3141
|
registry = _ref.registry;
|
|
3142
|
+
var translateString = registry.translateString;
|
|
3143
|
+
var dataURL = fileInfo.dataURL,
|
|
3144
|
+
type = fileInfo.type,
|
|
3145
|
+
name = fileInfo.name;
|
|
3146
|
+
if (!dataURL) {
|
|
3147
|
+
return null;
|
|
3148
|
+
}
|
|
3149
|
+
if (type.indexOf('image') !== -1) {
|
|
3150
|
+
return jsxRuntime.jsx("img", {
|
|
3151
|
+
src: dataURL,
|
|
3152
|
+
style: {
|
|
3153
|
+
maxWidth: '100%'
|
|
3154
|
+
},
|
|
3155
|
+
className: 'file-preview'
|
|
3156
|
+
});
|
|
3157
|
+
}
|
|
3158
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3159
|
+
children: [' ', jsxRuntime.jsx("a", {
|
|
3160
|
+
download: "preview-" + name,
|
|
3161
|
+
href: dataURL,
|
|
3162
|
+
className: 'file-download',
|
|
3163
|
+
children: translateString(utils.TranslatableString.PreviewLabel)
|
|
3164
|
+
})]
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
function FilesInfo(_ref2) {
|
|
3168
|
+
var filesInfo = _ref2.filesInfo,
|
|
3169
|
+
registry = _ref2.registry,
|
|
3170
|
+
preview = _ref2.preview;
|
|
3101
3171
|
if (filesInfo.length === 0) {
|
|
3102
3172
|
return null;
|
|
3103
3173
|
}
|
|
@@ -3108,10 +3178,13 @@ function FilesInfo(_ref) {
|
|
|
3108
3178
|
var name = fileInfo.name,
|
|
3109
3179
|
size = fileInfo.size,
|
|
3110
3180
|
type = fileInfo.type;
|
|
3111
|
-
return jsxRuntime.
|
|
3112
|
-
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3181
|
+
return jsxRuntime.jsxs("li", {
|
|
3182
|
+
children: [jsxRuntime.jsx(Markdown__default["default"], {
|
|
3113
3183
|
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3114
|
-
})
|
|
3184
|
+
}), preview && jsxRuntime.jsx(FileInfoPreview, {
|
|
3185
|
+
fileInfo: fileInfo,
|
|
3186
|
+
registry: registry
|
|
3187
|
+
})]
|
|
3115
3188
|
}, key);
|
|
3116
3189
|
})
|
|
3117
3190
|
});
|
|
@@ -3124,6 +3197,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3124
3197
|
blob = _dataURItoBlob.blob,
|
|
3125
3198
|
name = _dataURItoBlob.name;
|
|
3126
3199
|
return {
|
|
3200
|
+
dataURL: dataURL,
|
|
3127
3201
|
name: name,
|
|
3128
3202
|
size: blob.size,
|
|
3129
3203
|
type: blob.type
|
|
@@ -3174,7 +3248,8 @@ function FileWidget(props) {
|
|
|
3174
3248
|
accept: options.accept ? String(options.accept) : undefined
|
|
3175
3249
|
})), jsxRuntime.jsx(FilesInfo, {
|
|
3176
3250
|
filesInfo: filesInfo,
|
|
3177
|
-
registry: registry
|
|
3251
|
+
registry: registry,
|
|
3252
|
+
preview: options.filePreview
|
|
3178
3253
|
})]
|
|
3179
3254
|
});
|
|
3180
3255
|
}
|