@rjsf/mui 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.
@@ -228,7 +228,7 @@
228
228
  });
229
229
  }
230
230
 
231
- var _excluded$2 = ["id", "name", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onChangeOverride", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry", "InputLabelProps"],
231
+ var _excluded$2 = ["id", "name", "placeholder", "required", "readonly", "disabled", "type", "label", "hideLabel", "value", "onChange", "onChangeOverride", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry", "InputLabelProps"],
232
232
  _excluded2$1 = ["step", "min", "max"];
233
233
  var TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
234
234
  /** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
@@ -245,6 +245,7 @@
245
245
  disabled = props.disabled,
246
246
  type = props.type,
247
247
  label = props.label,
248
+ hideLabel = props.hideLabel,
248
249
  value = props.value,
249
250
  onChange = props.onChange,
250
251
  onChangeOverride = props.onChangeOverride,
@@ -253,10 +254,8 @@
253
254
  autofocus = props.autofocus,
254
255
  options = props.options,
255
256
  schema = props.schema,
256
- uiSchema = props.uiSchema,
257
257
  _props$rawErrors = props.rawErrors,
258
258
  rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
259
- registry = props.registry,
260
259
  InputLabelProps = props.InputLabelProps,
261
260
  textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$2);
262
261
  var inputProps = utils.getInputProps(schema, type, options);
@@ -286,8 +285,6 @@
286
285
  var value = _ref3.target.value;
287
286
  return onFocus(id, value);
288
287
  };
289
- var schemaUtils = registry.schemaUtils;
290
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
291
288
  var DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? _extends({}, InputLabelProps, {
292
289
  shrink: true
293
290
  }) : InputLabelProps;
@@ -296,7 +293,7 @@
296
293
  id: id,
297
294
  name: id,
298
295
  placeholder: placeholder,
299
- label: displayLabel ? label || schema.title : false,
296
+ label: utils.labelValue(label || undefined, hideLabel, false),
300
297
  autoFocus: autofocus,
301
298
  required: required,
302
299
  disabled: disabled || readonly
@@ -561,16 +558,16 @@
561
558
  // Button templates are not overridden in the uiSchema
562
559
  var AddButton = registry.templates.ButtonTemplates.AddButton;
563
560
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
564
- children: [(uiOptions.title || title) && jsxRuntime.jsx(TitleFieldTemplate, {
561
+ children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
565
562
  id: utils.titleId(idSchema),
566
563
  title: title,
567
564
  required: required,
568
565
  schema: schema,
569
566
  uiSchema: uiSchema,
570
567
  registry: registry
571
- }), (uiOptions.description || description) && jsxRuntime.jsx(DescriptionFieldTemplate, {
568
+ }), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
572
569
  id: utils.descriptionId(idSchema),
573
- description: uiOptions.description || description,
570
+ description: description,
574
571
  schema: schema,
575
572
  uiSchema: uiSchema,
576
573
  registry: registry
@@ -767,16 +764,23 @@
767
764
  * @param props - The `WidgetProps` for this component
768
765
  */
769
766
  function CheckboxWidget(props) {
767
+ var _options$description;
770
768
  var schema = props.schema,
771
769
  id = props.id,
772
770
  value = props.value,
773
771
  disabled = props.disabled,
774
772
  readonly = props.readonly,
775
- label = props.label,
773
+ _props$label = props.label,
774
+ label = _props$label === void 0 ? '' : _props$label,
775
+ hideLabel = props.hideLabel,
776
776
  autofocus = props.autofocus,
777
777
  onChange = props.onChange,
778
778
  onBlur = props.onBlur,
779
- onFocus = props.onFocus;
779
+ onFocus = props.onFocus,
780
+ registry = props.registry,
781
+ options = props.options,
782
+ uiSchema = props.uiSchema;
783
+ var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
780
784
  // Because an unchecked checkbox will cause html5 validation to fail, only add
781
785
  // the "required" attribute if the field value must be "true", due to the
782
786
  // "const" or "enum" keywords
@@ -792,20 +796,29 @@
792
796
  var value = _ref2.target.value;
793
797
  return onFocus(id, value);
794
798
  };
795
- return jsxRuntime.jsx(FormControlLabel__default["default"], {
796
- control: jsxRuntime.jsx(Checkbox__default["default"], {
797
- id: id,
798
- name: id,
799
- checked: typeof value === 'undefined' ? false : Boolean(value),
800
- required: required,
801
- disabled: disabled || readonly,
802
- autoFocus: autofocus,
803
- onChange: _onChange,
804
- onBlur: _onBlur,
805
- onFocus: _onFocus,
806
- "aria-describedby": utils.ariaDescribedByIds(id)
807
- }),
808
- label: label || ''
799
+ var description = (_options$description = options.description) != null ? _options$description : schema.description;
800
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
801
+ children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
802
+ id: utils.descriptionId(id),
803
+ description: description,
804
+ schema: schema,
805
+ uiSchema: uiSchema,
806
+ registry: registry
807
+ }), jsxRuntime.jsx(FormControlLabel__default["default"], {
808
+ control: jsxRuntime.jsx(Checkbox__default["default"], {
809
+ id: id,
810
+ name: id,
811
+ checked: typeof value === 'undefined' ? false : Boolean(value),
812
+ required: required,
813
+ disabled: disabled || readonly,
814
+ autoFocus: autofocus,
815
+ onChange: _onChange,
816
+ onBlur: _onBlur,
817
+ onFocus: _onFocus,
818
+ "aria-describedby": utils.ariaDescribedByIds(id)
819
+ }),
820
+ label: utils.labelValue(label, hideLabel, false)
821
+ })]
809
822
  });
810
823
  }
811
824
 
@@ -815,8 +828,8 @@
815
828
  * @param props - The `WidgetProps` for this component
816
829
  */
817
830
  function CheckboxesWidget(_ref) {
818
- var schema = _ref.schema,
819
- label = _ref.label,
831
+ var label = _ref.label,
832
+ hideLabel = _ref.hideLabel,
820
833
  id = _ref.id,
821
834
  disabled = _ref.disabled,
822
835
  options = _ref.options,
@@ -851,11 +864,11 @@
851
864
  return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
852
865
  };
853
866
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
854
- children: [jsxRuntime.jsx(FormLabel__default["default"], {
867
+ children: [utils.labelValue(jsxRuntime.jsx(FormLabel__default["default"], {
855
868
  required: required,
856
869
  htmlFor: id,
857
- children: label || schema.title
858
- }), jsxRuntime.jsx(FormGroup__default["default"], {
870
+ children: label || undefined
871
+ }), hideLabel), jsxRuntime.jsx(FormGroup__default["default"], {
859
872
  id: id,
860
873
  row: !!inline,
861
874
  children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
@@ -887,14 +900,15 @@
887
900
  * @param props - The `WidgetProps` for this component
888
901
  */
889
902
  function RadioWidget(_ref) {
903
+ var _enumOptionsIndexForV;
890
904
  var id = _ref.id,
891
- schema = _ref.schema,
892
905
  options = _ref.options,
893
906
  value = _ref.value,
894
907
  required = _ref.required,
895
908
  disabled = _ref.disabled,
896
909
  readonly = _ref.readonly,
897
910
  label = _ref.label,
911
+ hideLabel = _ref.hideLabel,
898
912
  onChange = _ref.onChange,
899
913
  onBlur = _ref.onBlur,
900
914
  onFocus = _ref.onFocus;
@@ -913,13 +927,13 @@
913
927
  return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
914
928
  };
915
929
  var row = options ? options.inline : false;
916
- var selectedIndex = utils.enumOptionsIndexForValue(value, enumOptions);
930
+ var selectedIndex = (_enumOptionsIndexForV = utils.enumOptionsIndexForValue(value, enumOptions)) != null ? _enumOptionsIndexForV : null;
917
931
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
918
- children: [jsxRuntime.jsx(FormLabel__default["default"], {
932
+ children: [utils.labelValue(jsxRuntime.jsx(FormLabel__default["default"], {
919
933
  required: required,
920
934
  htmlFor: id,
921
- children: label || schema.title
922
- }), jsxRuntime.jsx(RadioGroup__default["default"], {
935
+ children: label || undefined
936
+ }), hideLabel), jsxRuntime.jsx(RadioGroup__default["default"], {
923
937
  id: id,
924
938
  name: id,
925
939
  value: selectedIndex,
@@ -962,6 +976,7 @@
962
976
  onChange = props.onChange,
963
977
  required = props.required,
964
978
  label = props.label,
979
+ hideLabel = props.hideLabel,
965
980
  id = props.id;
966
981
  var sliderProps = _extends({
967
982
  value: value,
@@ -981,11 +996,11 @@
981
996
  return onFocus(id, value);
982
997
  };
983
998
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
984
- children: [jsxRuntime.jsx(FormLabel__default["default"], {
999
+ children: [utils.labelValue(jsxRuntime.jsx(FormLabel__default["default"], {
985
1000
  required: required,
986
1001
  htmlFor: id,
987
- children: label || schema.title
988
- }), jsxRuntime.jsx(Slider__default["default"], _extends({
1002
+ children: label || undefined
1003
+ }), hideLabel), jsxRuntime.jsx(Slider__default["default"], _extends({
989
1004
  disabled: disabled || readonly,
990
1005
  onChange: _onChange,
991
1006
  onBlur: _onBlur,
@@ -997,17 +1012,17 @@
997
1012
  });
998
1013
  }
999
1014
 
1000
- var _excluded = ["schema", "id", "name", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
1015
+ var _excluded = ["schema", "id", "name", "options", "label", "hideLabel", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
1001
1016
  /** The `SelectWidget` is a widget for rendering dropdowns.
1002
1017
  * It is typically used with string properties constrained with enum options.
1003
1018
  *
1004
1019
  * @param props - The `WidgetProps` for this component
1005
1020
  */
1006
1021
  function SelectWidget(_ref) {
1007
- var schema = _ref.schema,
1008
- id = _ref.id,
1022
+ var id = _ref.id,
1009
1023
  options = _ref.options,
1010
1024
  label = _ref.label,
1025
+ hideLabel = _ref.hideLabel,
1011
1026
  required = _ref.required,
1012
1027
  disabled = _ref.disabled,
1013
1028
  placeholder = _ref.placeholder,
@@ -1043,7 +1058,7 @@
1043
1058
  return jsxRuntime.jsx(TextField__default["default"], _extends({
1044
1059
  id: id,
1045
1060
  name: id,
1046
- label: label || schema.title,
1061
+ label: utils.labelValue(label || undefined, hideLabel, false),
1047
1062
  value: isEmpty ? emptyValue : selectedIndexes,
1048
1063
  required: required,
1049
1064
  disabled: disabled || readonly,