@rjsf/core 5.3.0 → 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 +138 -61
- 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 +139 -62
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +138 -61
- 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 -8
|
@@ -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
|
|
@@ -2758,22 +2796,25 @@ function AltDateWidget(_ref2) {
|
|
|
2758
2796
|
onChange = _ref2.onChange,
|
|
2759
2797
|
value = _ref2.value;
|
|
2760
2798
|
var translateString = registry.translateString;
|
|
2799
|
+
var _useState = react.useState(value),
|
|
2800
|
+
lastValue = _useState[0],
|
|
2801
|
+
setLastValue = _useState[1];
|
|
2761
2802
|
var _useReducer = react.useReducer(function (state, action) {
|
|
2762
2803
|
return _extends({}, state, action);
|
|
2763
2804
|
}, utils.parseDateString(value, time)),
|
|
2764
2805
|
state = _useReducer[0],
|
|
2765
2806
|
setState = _useReducer[1];
|
|
2766
2807
|
react.useEffect(function () {
|
|
2767
|
-
|
|
2808
|
+
var stateValue = utils.toDateString(state, time);
|
|
2809
|
+
if (readyForChange(state) && stateValue !== value) {
|
|
2810
|
+
// The user changed the date to a new valid data via the comboboxes, so call onChange
|
|
2811
|
+
onChange(stateValue);
|
|
2812
|
+
} else if (lastValue !== value) {
|
|
2813
|
+
// We got a new value in the props
|
|
2814
|
+
setLastValue(value);
|
|
2768
2815
|
setState(utils.parseDateString(value, time));
|
|
2769
2816
|
}
|
|
2770
|
-
}, [value, state,
|
|
2771
|
-
react.useEffect(function () {
|
|
2772
|
-
if (readyForChange(state)) {
|
|
2773
|
-
// Only propagate to parent state if we have a complete date{time}
|
|
2774
|
-
onChange(utils.toDateString(state, time));
|
|
2775
|
-
}
|
|
2776
|
-
}, [state, time, onChange]);
|
|
2817
|
+
}, [time, value, onChange, state, lastValue]);
|
|
2777
2818
|
var handleChange = react.useCallback(function (property, value) {
|
|
2778
2819
|
var _setState;
|
|
2779
2820
|
setState((_setState = {}, _setState[property] = value, _setState));
|
|
@@ -2783,17 +2824,16 @@ function AltDateWidget(_ref2) {
|
|
|
2783
2824
|
if (disabled || readonly) {
|
|
2784
2825
|
return;
|
|
2785
2826
|
}
|
|
2786
|
-
var
|
|
2787
|
-
|
|
2827
|
+
var nextState = utils.parseDateString(new Date().toJSON(), time);
|
|
2828
|
+
onChange(utils.toDateString(nextState, time));
|
|
2788
2829
|
}, [disabled, readonly, time]);
|
|
2789
2830
|
var handleClear = react.useCallback(function (event) {
|
|
2790
2831
|
event.preventDefault();
|
|
2791
2832
|
if (disabled || readonly) {
|
|
2792
2833
|
return;
|
|
2793
2834
|
}
|
|
2794
|
-
setState(utils.parseDateString('', time));
|
|
2795
2835
|
onChange(undefined);
|
|
2796
|
-
}, [disabled, readonly,
|
|
2836
|
+
}, [disabled, readonly, onChange]);
|
|
2797
2837
|
return jsxRuntime.jsxs("ul", {
|
|
2798
2838
|
className: 'list-inline',
|
|
2799
2839
|
children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
@@ -2854,6 +2894,7 @@ function AltDateTimeWidget(_ref) {
|
|
|
2854
2894
|
* @param props - The `WidgetProps` for this component
|
|
2855
2895
|
*/
|
|
2856
2896
|
function CheckboxWidget(_ref) {
|
|
2897
|
+
var _options$description;
|
|
2857
2898
|
var schema = _ref.schema,
|
|
2858
2899
|
uiSchema = _ref.uiSchema,
|
|
2859
2900
|
options = _ref.options,
|
|
@@ -2862,6 +2903,7 @@ function CheckboxWidget(_ref) {
|
|
|
2862
2903
|
disabled = _ref.disabled,
|
|
2863
2904
|
readonly = _ref.readonly,
|
|
2864
2905
|
label = _ref.label,
|
|
2906
|
+
hideLabel = _ref.hideLabel,
|
|
2865
2907
|
_ref$autofocus = _ref.autofocus,
|
|
2866
2908
|
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
2867
2909
|
onBlur = _ref.onBlur,
|
|
@@ -2882,11 +2924,12 @@ function CheckboxWidget(_ref) {
|
|
|
2882
2924
|
var handleFocus = react.useCallback(function (event) {
|
|
2883
2925
|
return onFocus(id, event.target.checked);
|
|
2884
2926
|
}, [onFocus, id]);
|
|
2927
|
+
var description = (_options$description = options.description) != null ? _options$description : schema.description;
|
|
2885
2928
|
return jsxRuntime.jsxs("div", {
|
|
2886
2929
|
className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
|
|
2887
|
-
children: [
|
|
2930
|
+
children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
2888
2931
|
id: utils.descriptionId(id),
|
|
2889
|
-
description:
|
|
2932
|
+
description: description,
|
|
2890
2933
|
schema: schema,
|
|
2891
2934
|
uiSchema: uiSchema,
|
|
2892
2935
|
registry: registry
|
|
@@ -2903,9 +2946,9 @@ function CheckboxWidget(_ref) {
|
|
|
2903
2946
|
onBlur: handleBlur,
|
|
2904
2947
|
onFocus: handleFocus,
|
|
2905
2948
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2906
|
-
}), jsxRuntime.jsx("span", {
|
|
2949
|
+
}), utils.labelValue(jsxRuntime.jsx("span", {
|
|
2907
2950
|
children: label
|
|
2908
|
-
})]
|
|
2951
|
+
}), hideLabel)]
|
|
2909
2952
|
})]
|
|
2910
2953
|
});
|
|
2911
2954
|
}
|
|
@@ -3093,9 +3136,38 @@ function processFile(file) {
|
|
|
3093
3136
|
function processFiles(files) {
|
|
3094
3137
|
return Promise.all(Array.from(files).map(processFile));
|
|
3095
3138
|
}
|
|
3096
|
-
function
|
|
3097
|
-
var
|
|
3139
|
+
function FileInfoPreview(_ref) {
|
|
3140
|
+
var fileInfo = _ref.fileInfo,
|
|
3098
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;
|
|
3099
3171
|
if (filesInfo.length === 0) {
|
|
3100
3172
|
return null;
|
|
3101
3173
|
}
|
|
@@ -3106,10 +3178,13 @@ function FilesInfo(_ref) {
|
|
|
3106
3178
|
var name = fileInfo.name,
|
|
3107
3179
|
size = fileInfo.size,
|
|
3108
3180
|
type = fileInfo.type;
|
|
3109
|
-
return jsxRuntime.
|
|
3110
|
-
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
3181
|
+
return jsxRuntime.jsxs("li", {
|
|
3182
|
+
children: [jsxRuntime.jsx(Markdown__default["default"], {
|
|
3111
3183
|
children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])
|
|
3112
|
-
})
|
|
3184
|
+
}), preview && jsxRuntime.jsx(FileInfoPreview, {
|
|
3185
|
+
fileInfo: fileInfo,
|
|
3186
|
+
registry: registry
|
|
3187
|
+
})]
|
|
3113
3188
|
}, key);
|
|
3114
3189
|
})
|
|
3115
3190
|
});
|
|
@@ -3122,6 +3197,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3122
3197
|
blob = _dataURItoBlob.blob,
|
|
3123
3198
|
name = _dataURItoBlob.name;
|
|
3124
3199
|
return {
|
|
3200
|
+
dataURL: dataURL,
|
|
3125
3201
|
name: name,
|
|
3126
3202
|
size: blob.size,
|
|
3127
3203
|
type: blob.type
|
|
@@ -3172,7 +3248,8 @@ function FileWidget(props) {
|
|
|
3172
3248
|
accept: options.accept ? String(options.accept) : undefined
|
|
3173
3249
|
})), jsxRuntime.jsx(FilesInfo, {
|
|
3174
3250
|
filesInfo: filesInfo,
|
|
3175
|
-
registry: registry
|
|
3251
|
+
registry: registry,
|
|
3252
|
+
preview: options.filePreview
|
|
3176
3253
|
})]
|
|
3177
3254
|
});
|
|
3178
3255
|
}
|