@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.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { Component, useState, useCallback, useEffect, useReducer, useMemo, createRef, forwardRef } from 'react';
3
- import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, UI_GLOBAL_OPTIONS_KEY, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
3
+ import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, labelValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, UI_GLOBAL_OPTIONS_KEY, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
4
4
  import get from 'lodash-es/get';
5
5
  import isEmpty from 'lodash-es/isEmpty';
6
6
  import _pick from 'lodash-es/pick';
@@ -84,9 +84,9 @@ function _toPropertyKey(arg) {
84
84
  return typeof key === "symbol" ? key : String(key);
85
85
  }
86
86
 
87
- var _excluded$9 = ["widget"],
88
- _excluded2 = ["widget"],
89
- _excluded3 = ["widget"];
87
+ var _excluded$9 = ["widget", "title"],
88
+ _excluded2 = ["widget", "title"],
89
+ _excluded3 = ["widget", "title"];
90
90
  /** Used to generate a unique ID for an element in a row */
91
91
  function generateRowId() {
92
92
  return nanoid();
@@ -507,6 +507,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
507
507
  /** Renders an array using the custom widget provided by the user in the `uiSchema`
508
508
  */;
509
509
  _proto.renderCustomWidget = function renderCustomWidget() {
510
+ var _ref;
510
511
  var _this$props9 = this.props,
511
512
  schema = _this$props9.schema,
512
513
  idSchema = _this$props9.idSchema,
@@ -529,12 +530,16 @@ var ArrayField = /*#__PURE__*/function (_Component) {
529
530
  rawErrors = _this$props9.rawErrors,
530
531
  name = _this$props9.name;
531
532
  var widgets = registry.widgets,
532
- formContext = registry.formContext;
533
- var title = schema.title || name;
534
- var _getUiOptions2 = getUiOptions(uiSchema),
533
+ formContext = registry.formContext,
534
+ globalUiOptions = registry.globalUiOptions,
535
+ schemaUtils = registry.schemaUtils;
536
+ var _getUiOptions2 = getUiOptions(uiSchema, globalUiOptions),
535
537
  widget = _getUiOptions2.widget,
538
+ uiTitle = _getUiOptions2.title,
536
539
  options = _objectWithoutPropertiesLoose(_getUiOptions2, _excluded$9);
537
540
  var Widget = getWidget(schema, widget, widgets);
541
+ var label = (_ref = uiTitle != null ? uiTitle : schema.title) != null ? _ref : name;
542
+ var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
538
543
  return jsx(Widget, {
539
544
  id: idSchema.$id,
540
545
  name: name,
@@ -551,7 +556,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
551
556
  readonly: readonly,
552
557
  hideError: hideError,
553
558
  required: required,
554
- label: title,
559
+ label: label,
560
+ hideLabel: !displayLabel,
555
561
  placeholder: placeholder,
556
562
  formContext: formContext,
557
563
  autofocus: autofocus,
@@ -561,6 +567,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
561
567
  /** Renders an array as a set of checkboxes
562
568
  */;
563
569
  _proto.renderMultiSelect = function renderMultiSelect() {
570
+ var _ref2;
564
571
  var _this$props10 = this.props,
565
572
  schema = _this$props10.schema,
566
573
  idSchema = _this$props10.idSchema,
@@ -583,15 +590,18 @@ var ArrayField = /*#__PURE__*/function (_Component) {
583
590
  name = _this$props10.name;
584
591
  var widgets = registry.widgets,
585
592
  schemaUtils = registry.schemaUtils,
586
- formContext = registry.formContext;
593
+ formContext = registry.formContext,
594
+ globalUiOptions = registry.globalUiOptions;
587
595
  var itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
588
- var title = schema.title || name;
589
596
  var enumOptions = optionsList(itemsSchema);
590
- var _getUiOptions3 = getUiOptions(uiSchema),
597
+ var _getUiOptions3 = getUiOptions(uiSchema, globalUiOptions),
591
598
  _getUiOptions3$widget = _getUiOptions3.widget,
592
599
  widget = _getUiOptions3$widget === void 0 ? 'select' : _getUiOptions3$widget,
600
+ uiTitle = _getUiOptions3.title,
593
601
  options = _objectWithoutPropertiesLoose(_getUiOptions3, _excluded2);
594
602
  var Widget = getWidget(schema, widget, widgets);
603
+ var label = (_ref2 = uiTitle != null ? uiTitle : schema.title) != null ? _ref2 : name;
604
+ var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
595
605
  return jsx(Widget, {
596
606
  id: idSchema.$id,
597
607
  name: name,
@@ -609,7 +619,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
609
619
  disabled: disabled,
610
620
  readonly: readonly,
611
621
  required: required,
612
- label: title,
622
+ label: label,
623
+ hideLabel: !displayLabel,
613
624
  placeholder: placeholder,
614
625
  formContext: formContext,
615
626
  autofocus: autofocus,
@@ -619,6 +630,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
619
630
  /** Renders an array of files using the `FileWidget`
620
631
  */;
621
632
  _proto.renderFiles = function renderFiles() {
633
+ var _ref3;
622
634
  var _this$props11 = this.props,
623
635
  schema = _this$props11.schema,
624
636
  uiSchema = _this$props11.uiSchema,
@@ -638,14 +650,18 @@ var ArrayField = /*#__PURE__*/function (_Component) {
638
650
  _this$props11$formDat = _this$props11.formData,
639
651
  items = _this$props11$formDat === void 0 ? [] : _this$props11$formDat,
640
652
  rawErrors = _this$props11.rawErrors;
641
- var title = schema.title || name;
642
653
  var widgets = registry.widgets,
643
- formContext = registry.formContext;
644
- var _getUiOptions4 = getUiOptions(uiSchema),
654
+ formContext = registry.formContext,
655
+ globalUiOptions = registry.globalUiOptions,
656
+ schemaUtils = registry.schemaUtils;
657
+ var _getUiOptions4 = getUiOptions(uiSchema, globalUiOptions),
645
658
  _getUiOptions4$widget = _getUiOptions4.widget,
646
659
  widget = _getUiOptions4$widget === void 0 ? 'files' : _getUiOptions4$widget,
660
+ uiTitle = _getUiOptions4.title,
647
661
  options = _objectWithoutPropertiesLoose(_getUiOptions4, _excluded3);
648
662
  var Widget = getWidget(schema, widget, widgets);
663
+ var label = (_ref3 = uiTitle != null ? uiTitle : schema.title) != null ? _ref3 : name;
664
+ var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
649
665
  return jsx(Widget, {
650
666
  options: options,
651
667
  id: idSchema.$id,
@@ -656,7 +672,6 @@ var ArrayField = /*#__PURE__*/function (_Component) {
656
672
  onFocus: onFocus,
657
673
  schema: schema,
658
674
  uiSchema: uiSchema,
659
- title: title,
660
675
  value: items,
661
676
  disabled: disabled,
662
677
  readonly: readonly,
@@ -665,7 +680,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
665
680
  formContext: formContext,
666
681
  autofocus: autofocus,
667
682
  rawErrors: rawErrors,
668
- label: ''
683
+ label: label,
684
+ hideLabel: !displayLabel
669
685
  });
670
686
  }
671
687
  /** Renders an array that has a maximum limit of items
@@ -877,13 +893,14 @@ var ArrayField = /*#__PURE__*/function (_Component) {
877
893
  return ArrayField;
878
894
  }(Component);
879
895
 
880
- var _excluded$8 = ["widget"];
896
+ var _excluded$8 = ["widget", "title", "label"];
881
897
  /** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
882
898
  * two boolean values based on the various alternatives in the schema.
883
899
  *
884
900
  * @param props - The `FieldProps` for this template
885
901
  */
886
902
  function BooleanField(props) {
903
+ var _ref;
887
904
  var schema = props.schema,
888
905
  name = props.name,
889
906
  uiSchema = props.uiSchema,
@@ -901,15 +918,20 @@ function BooleanField(props) {
901
918
  var title = schema.title;
902
919
  var widgets = registry.widgets,
903
920
  formContext = registry.formContext,
904
- translateString = registry.translateString;
905
- var _getUiOptions = getUiOptions(uiSchema),
921
+ translateString = registry.translateString,
922
+ globalUiOptions = registry.globalUiOptions;
923
+ var _getUiOptions = getUiOptions(uiSchema, globalUiOptions),
906
924
  _getUiOptions$widget = _getUiOptions.widget,
907
925
  widget = _getUiOptions$widget === void 0 ? 'checkbox' : _getUiOptions$widget,
926
+ uiTitle = _getUiOptions.title,
927
+ _getUiOptions$label = _getUiOptions.label,
928
+ displayLabel = _getUiOptions$label === void 0 ? true : _getUiOptions$label,
908
929
  options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
909
930
  var Widget = getWidget(schema, widget, widgets);
910
931
  var yes = translateString(TranslatableString.YesLabel);
911
932
  var no = translateString(TranslatableString.NoLabel);
912
933
  var enumOptions;
934
+ var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
913
935
  if (Array.isArray(schema.oneOf)) {
914
936
  enumOptions = optionsList({
915
937
  oneOf: schema.oneOf.map(function (option) {
@@ -957,7 +979,8 @@ function BooleanField(props) {
957
979
  onChange: onChange,
958
980
  onFocus: onFocus,
959
981
  onBlur: onBlur,
960
- label: title === undefined ? name : title,
982
+ label: label,
983
+ hideLabel: !displayLabel,
961
984
  value: formData,
962
985
  required: required,
963
986
  disabled: disabled,
@@ -1110,12 +1133,14 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1110
1133
  uiSchema = _this$props5.uiSchema;
1111
1134
  var widgets = registry.widgets,
1112
1135
  fields = registry.fields,
1113
- translateString = registry.translateString;
1136
+ translateString = registry.translateString,
1137
+ globalUiOptions = registry.globalUiOptions,
1138
+ schemaUtils = registry.schemaUtils;
1114
1139
  var _SchemaField = fields.SchemaField;
1115
1140
  var _this$state2 = this.state,
1116
1141
  selectedOption = _this$state2.selectedOption,
1117
1142
  retrievedOptions = _this$state2.retrievedOptions;
1118
- var _getUiOptions = getUiOptions(uiSchema),
1143
+ var _getUiOptions = getUiOptions(uiSchema, globalUiOptions),
1119
1144
  _getUiOptions$widget = _getUiOptions.widget,
1120
1145
  widget = _getUiOptions$widget === void 0 ? 'select' : _getUiOptions$widget,
1121
1146
  placeholder = _getUiOptions.placeholder,
@@ -1129,6 +1154,7 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1129
1154
  }, widget, widgets);
1130
1155
  var rawErrors = get(errorSchema, ERRORS_KEY, []);
1131
1156
  var fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
1157
+ var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1132
1158
  var option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1133
1159
  var optionSchema;
1134
1160
  if (option) {
@@ -1173,7 +1199,8 @@ var AnyOfField = /*#__PURE__*/function (_Component) {
1173
1199
  placeholder: placeholder,
1174
1200
  autocomplete: autocomplete,
1175
1201
  autofocus: autofocus,
1176
- label: ''
1202
+ label: title != null ? title : name,
1203
+ hideLabel: !displayLabel
1177
1204
  })
1178
1205
  }), option !== null && jsx(_SchemaField, _extends({}, this.props, {
1179
1206
  schema: optionSchema
@@ -1428,7 +1455,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
1428
1455
  /** Renders the `ObjectField` from the given props
1429
1456
  */
1430
1457
  _proto.render = function render() {
1431
- var _this2 = this;
1458
+ var _ref2,
1459
+ _uiOptions$title,
1460
+ _uiOptions$descriptio,
1461
+ _this2 = this;
1432
1462
  var _this$props6 = this.props,
1433
1463
  rawSchema = _this$props6.schema,
1434
1464
  _this$props6$uiSchema = _this$props6.uiSchema,
@@ -1452,14 +1482,15 @@ var ObjectField = /*#__PURE__*/function (_Component) {
1452
1482
  var fields = registry.fields,
1453
1483
  formContext = registry.formContext,
1454
1484
  schemaUtils = registry.schemaUtils,
1455
- translateString = registry.translateString;
1485
+ translateString = registry.translateString,
1486
+ globalUiOptions = registry.globalUiOptions;
1456
1487
  var SchemaField = fields.SchemaField;
1457
1488
  var schema = schemaUtils.retrieveSchema(rawSchema, formData);
1458
- var uiOptions = getUiOptions(uiSchema);
1489
+ var uiOptions = getUiOptions(uiSchema, globalUiOptions);
1459
1490
  var _schema$properties = schema.properties,
1460
1491
  schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
1461
- var title = uiOptions.title || (schema.title === undefined ? name : schema.title);
1462
- var description = uiOptions.description || schema.description;
1492
+ var title = (_ref2 = (_uiOptions$title = uiOptions.title) != null ? _uiOptions$title : schema.title) != null ? _ref2 : name;
1493
+ var description = (_uiOptions$descriptio = uiOptions.description) != null ? _uiOptions$descriptio : schema.description;
1463
1494
  var orderedProperties;
1464
1495
  try {
1465
1496
  var properties = Object.keys(schemaProperties);
@@ -1481,8 +1512,9 @@ var ObjectField = /*#__PURE__*/function (_Component) {
1481
1512
  }
1482
1513
  var Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
1483
1514
  var templateProps = {
1484
- title: title,
1485
- description: description,
1515
+ // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
1516
+ title: uiOptions.label === false ? '' : title,
1517
+ description: uiOptions.label === false ? undefined : description,
1486
1518
  properties: orderedProperties.map(function (name) {
1487
1519
  var addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
1488
1520
  var fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
@@ -1799,12 +1831,13 @@ var SchemaField = /*#__PURE__*/function (_Component) {
1799
1831
  return SchemaField;
1800
1832
  }(Component);
1801
1833
 
1802
- var _excluded$5 = ["widget", "placeholder"];
1834
+ var _excluded$5 = ["widget", "placeholder", "title"];
1803
1835
  /** The `StringField` component is used to render a schema field that represents a string type
1804
1836
  *
1805
1837
  * @param props - The `FieldProps` for this template
1806
1838
  */
1807
1839
  function StringField(props) {
1840
+ var _ref;
1808
1841
  var schema = props.schema,
1809
1842
  name = props.name,
1810
1843
  uiSchema = props.uiSchema,
@@ -1826,7 +1859,8 @@ function StringField(props) {
1826
1859
  format = schema.format;
1827
1860
  var widgets = registry.widgets,
1828
1861
  formContext = registry.formContext,
1829
- schemaUtils = registry.schemaUtils;
1862
+ schemaUtils = registry.schemaUtils,
1863
+ globalUiOptions = registry.globalUiOptions;
1830
1864
  var enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema) : undefined;
1831
1865
  var defaultWidget = enumOptions ? 'select' : 'text';
1832
1866
  if (format && hasWidget(schema, format, widgets)) {
@@ -1837,7 +1871,10 @@ function StringField(props) {
1837
1871
  widget = _getUiOptions$widget === void 0 ? defaultWidget : _getUiOptions$widget,
1838
1872
  _getUiOptions$placeho = _getUiOptions.placeholder,
1839
1873
  placeholder = _getUiOptions$placeho === void 0 ? '' : _getUiOptions$placeho,
1874
+ uiTitle = _getUiOptions.title,
1840
1875
  options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$5);
1876
+ var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1877
+ var label = (_ref = uiTitle != null ? uiTitle : title) != null ? _ref : name;
1841
1878
  var Widget = getWidget(schema, widget, widgets);
1842
1879
  return jsx(Widget, {
1843
1880
  options: _extends({}, options, {
@@ -1847,7 +1884,8 @@ function StringField(props) {
1847
1884
  uiSchema: uiSchema,
1848
1885
  id: idSchema.$id,
1849
1886
  name: name,
1850
- label: title === undefined ? name : title,
1887
+ label: label,
1888
+ hideLabel: !displayLabel,
1851
1889
  value: formData,
1852
1890
  onChange: onChange,
1853
1891
  onBlur: onBlur,
@@ -1905,7 +1943,7 @@ function ArrayFieldDescriptionTemplate(props) {
1905
1943
  registry = props.registry,
1906
1944
  schema = props.schema,
1907
1945
  uiSchema = props.uiSchema;
1908
- var options = getUiOptions(uiSchema);
1946
+ var options = getUiOptions(uiSchema, registry.globalUiOptions);
1909
1947
  var _options$label = options.label,
1910
1948
  displayLabel = _options$label === void 0 ? true : _options$label;
1911
1949
  if (!description || !displayLabel) {
@@ -2064,7 +2102,7 @@ function ArrayFieldTitleTemplate(props) {
2064
2102
  uiSchema = props.uiSchema,
2065
2103
  required = props.required,
2066
2104
  registry = props.registry;
2067
- var options = getUiOptions(uiSchema);
2105
+ var options = getUiOptions(uiSchema, registry.globalUiOptions);
2068
2106
  var _options$label = options.label,
2069
2107
  displayLabel = _options$label === void 0 ? true : _options$label;
2070
2108
  if (!title || !displayLabel) {
@@ -2453,16 +2491,16 @@ function ObjectFieldTemplate(props) {
2453
2491
  var AddButton = registry.templates.ButtonTemplates.AddButton;
2454
2492
  return jsxs("fieldset", {
2455
2493
  id: idSchema.$id,
2456
- children: [(options.title || title) && jsx(TitleFieldTemplate, {
2494
+ children: [title && jsx(TitleFieldTemplate, {
2457
2495
  id: titleId(idSchema),
2458
- title: options.title || title,
2496
+ title: title,
2459
2497
  required: required,
2460
2498
  schema: schema,
2461
2499
  uiSchema: uiSchema,
2462
2500
  registry: registry
2463
- }), (options.description || description) && jsx(DescriptionFieldTemplate, {
2501
+ }), description && jsx(DescriptionFieldTemplate, {
2464
2502
  id: descriptionId(idSchema),
2465
- description: options.description || description,
2503
+ description: description,
2466
2504
  schema: schema,
2467
2505
  uiSchema: uiSchema,
2468
2506
  registry: registry
@@ -2740,22 +2778,25 @@ function AltDateWidget(_ref2) {
2740
2778
  onChange = _ref2.onChange,
2741
2779
  value = _ref2.value;
2742
2780
  var translateString = registry.translateString;
2781
+ var _useState = useState(value),
2782
+ lastValue = _useState[0],
2783
+ setLastValue = _useState[1];
2743
2784
  var _useReducer = useReducer(function (state, action) {
2744
2785
  return _extends({}, state, action);
2745
2786
  }, parseDateString(value, time)),
2746
2787
  state = _useReducer[0],
2747
2788
  setState = _useReducer[1];
2748
2789
  useEffect(function () {
2749
- if (value && value !== toDateString(state, time)) {
2790
+ var stateValue = toDateString(state, time);
2791
+ if (readyForChange(state) && stateValue !== value) {
2792
+ // The user changed the date to a new valid data via the comboboxes, so call onChange
2793
+ onChange(stateValue);
2794
+ } else if (lastValue !== value) {
2795
+ // We got a new value in the props
2796
+ setLastValue(value);
2750
2797
  setState(parseDateString(value, time));
2751
2798
  }
2752
- }, [value, state, time]);
2753
- useEffect(function () {
2754
- if (readyForChange(state)) {
2755
- // Only propagate to parent state if we have a complete date{time}
2756
- onChange(toDateString(state, time));
2757
- }
2758
- }, [state, time, onChange]);
2799
+ }, [time, value, onChange, state, lastValue]);
2759
2800
  var handleChange = useCallback(function (property, value) {
2760
2801
  var _setState;
2761
2802
  setState((_setState = {}, _setState[property] = value, _setState));
@@ -2765,17 +2806,16 @@ function AltDateWidget(_ref2) {
2765
2806
  if (disabled || readonly) {
2766
2807
  return;
2767
2808
  }
2768
- var nowDateObj = parseDateString(new Date().toJSON(), time);
2769
- setState(nowDateObj);
2809
+ var nextState = parseDateString(new Date().toJSON(), time);
2810
+ onChange(toDateString(nextState, time));
2770
2811
  }, [disabled, readonly, time]);
2771
2812
  var handleClear = useCallback(function (event) {
2772
2813
  event.preventDefault();
2773
2814
  if (disabled || readonly) {
2774
2815
  return;
2775
2816
  }
2776
- setState(parseDateString('', time));
2777
2817
  onChange(undefined);
2778
- }, [disabled, readonly, time, onChange]);
2818
+ }, [disabled, readonly, onChange]);
2779
2819
  return jsxs("ul", {
2780
2820
  className: 'list-inline',
2781
2821
  children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
@@ -2836,6 +2876,7 @@ function AltDateTimeWidget(_ref) {
2836
2876
  * @param props - The `WidgetProps` for this component
2837
2877
  */
2838
2878
  function CheckboxWidget(_ref) {
2879
+ var _options$description;
2839
2880
  var schema = _ref.schema,
2840
2881
  uiSchema = _ref.uiSchema,
2841
2882
  options = _ref.options,
@@ -2844,6 +2885,7 @@ function CheckboxWidget(_ref) {
2844
2885
  disabled = _ref.disabled,
2845
2886
  readonly = _ref.readonly,
2846
2887
  label = _ref.label,
2888
+ hideLabel = _ref.hideLabel,
2847
2889
  _ref$autofocus = _ref.autofocus,
2848
2890
  autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
2849
2891
  onBlur = _ref.onBlur,
@@ -2864,11 +2906,12 @@ function CheckboxWidget(_ref) {
2864
2906
  var handleFocus = useCallback(function (event) {
2865
2907
  return onFocus(id, event.target.checked);
2866
2908
  }, [onFocus, id]);
2909
+ var description = (_options$description = options.description) != null ? _options$description : schema.description;
2867
2910
  return jsxs("div", {
2868
2911
  className: "checkbox " + (disabled || readonly ? 'disabled' : ''),
2869
- children: [schema.description && jsx(DescriptionFieldTemplate, {
2912
+ children: [!hideLabel && !!description && jsx(DescriptionFieldTemplate, {
2870
2913
  id: descriptionId(id),
2871
- description: schema.description,
2914
+ description: description,
2872
2915
  schema: schema,
2873
2916
  uiSchema: uiSchema,
2874
2917
  registry: registry
@@ -2885,9 +2928,9 @@ function CheckboxWidget(_ref) {
2885
2928
  onBlur: handleBlur,
2886
2929
  onFocus: handleFocus,
2887
2930
  "aria-describedby": ariaDescribedByIds(id)
2888
- }), jsx("span", {
2931
+ }), labelValue(jsx("span", {
2889
2932
  children: label
2890
- })]
2933
+ }), hideLabel)]
2891
2934
  })]
2892
2935
  });
2893
2936
  }
@@ -3075,9 +3118,38 @@ function processFile(file) {
3075
3118
  function processFiles(files) {
3076
3119
  return Promise.all(Array.from(files).map(processFile));
3077
3120
  }
3078
- function FilesInfo(_ref) {
3079
- var filesInfo = _ref.filesInfo,
3121
+ function FileInfoPreview(_ref) {
3122
+ var fileInfo = _ref.fileInfo,
3080
3123
  registry = _ref.registry;
3124
+ var translateString = registry.translateString;
3125
+ var dataURL = fileInfo.dataURL,
3126
+ type = fileInfo.type,
3127
+ name = fileInfo.name;
3128
+ if (!dataURL) {
3129
+ return null;
3130
+ }
3131
+ if (type.indexOf('image') !== -1) {
3132
+ return jsx("img", {
3133
+ src: dataURL,
3134
+ style: {
3135
+ maxWidth: '100%'
3136
+ },
3137
+ className: 'file-preview'
3138
+ });
3139
+ }
3140
+ return jsxs(Fragment, {
3141
+ children: [' ', jsx("a", {
3142
+ download: "preview-" + name,
3143
+ href: dataURL,
3144
+ className: 'file-download',
3145
+ children: translateString(TranslatableString.PreviewLabel)
3146
+ })]
3147
+ });
3148
+ }
3149
+ function FilesInfo(_ref2) {
3150
+ var filesInfo = _ref2.filesInfo,
3151
+ registry = _ref2.registry,
3152
+ preview = _ref2.preview;
3081
3153
  if (filesInfo.length === 0) {
3082
3154
  return null;
3083
3155
  }
@@ -3088,10 +3160,13 @@ function FilesInfo(_ref) {
3088
3160
  var name = fileInfo.name,
3089
3161
  size = fileInfo.size,
3090
3162
  type = fileInfo.type;
3091
- return jsx("li", {
3092
- children: jsx(Markdown, {
3163
+ return jsxs("li", {
3164
+ children: [jsx(Markdown, {
3093
3165
  children: translateString(TranslatableString.FilesInfo, [name, type, String(size)])
3094
- })
3166
+ }), preview && jsx(FileInfoPreview, {
3167
+ fileInfo: fileInfo,
3168
+ registry: registry
3169
+ })]
3095
3170
  }, key);
3096
3171
  })
3097
3172
  });
@@ -3104,6 +3179,7 @@ function extractFileInfo(dataURLs) {
3104
3179
  blob = _dataURItoBlob.blob,
3105
3180
  name = _dataURItoBlob.name;
3106
3181
  return {
3182
+ dataURL: dataURL,
3107
3183
  name: name,
3108
3184
  size: blob.size,
3109
3185
  type: blob.type
@@ -3154,7 +3230,8 @@ function FileWidget(props) {
3154
3230
  accept: options.accept ? String(options.accept) : undefined
3155
3231
  })), jsx(FilesInfo, {
3156
3232
  filesInfo: filesInfo,
3157
- registry: registry
3233
+ registry: registry,
3234
+ preview: options.filePreview
3158
3235
  })]
3159
3236
  });
3160
3237
  }