@rjsf/chakra-ui 5.3.1 → 5.5.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.
@@ -197,6 +197,7 @@
197
197
  type = props.type,
198
198
  value = props.value,
199
199
  label = props.label,
200
+ hideLabel = props.hideLabel,
200
201
  schema = props.schema,
201
202
  uiSchema = props.uiSchema,
202
203
  onChange = props.onChange,
@@ -209,13 +210,11 @@
209
210
  rawErrors = props.rawErrors,
210
211
  autofocus = props.autofocus,
211
212
  placeholder = props.placeholder,
212
- disabled = props.disabled,
213
- registry = props.registry;
213
+ disabled = props.disabled;
214
214
  var inputProps = utils.getInputProps(schema, type, options);
215
215
  var chakraProps = getChakra({
216
216
  uiSchema: uiSchema
217
217
  });
218
- var schemaUtils = registry.schemaUtils;
219
218
  var _onChange = function _onChange(_ref) {
220
219
  var value = _ref.target.value;
221
220
  return onChange(value === '' ? options.emptyValue : value);
@@ -228,7 +227,6 @@
228
227
  var value = _ref3.target.value;
229
228
  return onFocus(id, value);
230
229
  };
231
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema) && (!!label || !!schema.title);
232
230
  return jsxRuntime.jsxs(react.FormControl, _extends({
233
231
  mb: 1
234
232
  }, chakraProps, {
@@ -236,11 +234,11 @@
236
234
  isRequired: required,
237
235
  isReadOnly: readonly,
238
236
  isInvalid: rawErrors && rawErrors.length > 0,
239
- children: [displayLabel ? jsxRuntime.jsx(react.FormLabel, {
237
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
240
238
  htmlFor: id,
241
239
  id: id + "-label",
242
- children: label || schema.title
243
- }) : null, jsxRuntime.jsx(react.Input, _extends({
240
+ children: label
241
+ }), hideLabel || !label), jsxRuntime.jsx(react.Input, _extends({
244
242
  id: id,
245
243
  name: id,
246
244
  value: value || value === 0 ? value : '',
@@ -467,16 +465,16 @@
467
465
  // Button templates are not overridden in the uiSchema
468
466
  var AddButton = registry.templates.ButtonTemplates.AddButton;
469
467
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
470
- children: [(uiOptions.title || title) && jsxRuntime.jsx(TitleFieldTemplate, {
468
+ children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
471
469
  id: utils.titleId(idSchema),
472
- title: uiOptions.title || title,
470
+ title: title,
473
471
  required: required,
474
472
  schema: schema,
475
473
  uiSchema: uiSchema,
476
474
  registry: registry
477
- }), (uiOptions.description || description) && jsxRuntime.jsx(DescriptionFieldTemplate, {
475
+ }), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
478
476
  id: utils.descriptionId(idSchema),
479
- description: uiOptions.description || description,
477
+ description: description,
480
478
  schema: schema,
481
479
  uiSchema: uiSchema,
482
480
  registry: registry
@@ -812,6 +810,9 @@
812
810
  onBlur = props.onBlur,
813
811
  onFocus = props.onFocus,
814
812
  label = props.label,
813
+ hideLabel = props.hideLabel,
814
+ registry = props.registry,
815
+ options = props.options,
815
816
  uiSchema = props.uiSchema,
816
817
  schema = props.schema;
817
818
  var chakraProps = getChakra({
@@ -821,6 +822,8 @@
821
822
  // the "required" attribute if the field value must be "true", due to the
822
823
  // "const" or "enum" keywords
823
824
  var required = utils.schemaRequiresTrueValue(schema);
825
+ var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
826
+ var description = options.description || schema.description;
824
827
  var _onChange = function _onChange(_ref) {
825
828
  var checked = _ref.target.checked;
826
829
  return onChange(checked);
@@ -833,11 +836,17 @@
833
836
  var value = _ref3.target.value;
834
837
  return onFocus(id, value);
835
838
  };
836
- return jsxRuntime.jsx(react.FormControl, _extends({
839
+ return jsxRuntime.jsxs(react.FormControl, _extends({
837
840
  mb: 1
838
841
  }, chakraProps, {
839
842
  isRequired: required,
840
- children: jsxRuntime.jsx(react.Checkbox, {
843
+ children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
844
+ id: utils.descriptionId(id),
845
+ description: description,
846
+ schema: schema,
847
+ uiSchema: uiSchema,
848
+ registry: registry
849
+ }), jsxRuntime.jsx(react.Checkbox, {
841
850
  id: id,
842
851
  name: id,
843
852
  isChecked: typeof value === 'undefined' ? false : value,
@@ -846,10 +855,10 @@
846
855
  onBlur: _onBlur,
847
856
  onFocus: _onFocus,
848
857
  "aria-describedby": utils.ariaDescribedByIds(id),
849
- children: label && jsxRuntime.jsx(react.Text, {
858
+ children: utils.labelValue(jsxRuntime.jsx(react.Text, {
850
859
  children: label
851
- })
852
- })
860
+ }), hideLabel || !label)
861
+ })]
853
862
  }));
854
863
  }
855
864
 
@@ -864,10 +873,10 @@
864
873
  onFocus = props.onFocus,
865
874
  required = props.required,
866
875
  label = props.label,
876
+ hideLabel = props.hideLabel,
867
877
  uiSchema = props.uiSchema,
868
878
  _props$rawErrors = props.rawErrors,
869
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
870
- schema = props.schema;
879
+ rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
871
880
  var enumOptions = options.enumOptions,
872
881
  enumDisabled = options.enumDisabled,
873
882
  emptyValue = options.emptyValue;
@@ -892,11 +901,11 @@
892
901
  isRequired: required,
893
902
  isReadOnly: readonly,
894
903
  isInvalid: rawErrors && rawErrors.length > 0,
895
- children: [jsxRuntime.jsx(react.FormLabel, {
904
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
896
905
  htmlFor: id,
897
906
  id: id + "-label",
898
- children: label || schema.title
899
- }), jsxRuntime.jsx(react.CheckboxGroup, {
907
+ children: label
908
+ }), hideLabel || !label), jsxRuntime.jsx(react.CheckboxGroup, {
900
909
  onChange: function onChange(option) {
901
910
  return _onChange(utils.enumOptionsValueForIndex(option, enumOptions, emptyValue));
902
911
  },
@@ -926,14 +935,15 @@
926
935
  }
927
936
 
928
937
  function RadioWidget(_ref) {
938
+ var _enumOptionsIndexForV;
929
939
  var id = _ref.id,
930
- schema = _ref.schema,
931
940
  options = _ref.options,
932
941
  value = _ref.value,
933
942
  required = _ref.required,
934
943
  disabled = _ref.disabled,
935
944
  readonly = _ref.readonly,
936
945
  label = _ref.label,
946
+ hideLabel = _ref.hideLabel,
937
947
  onChange = _ref.onChange,
938
948
  onBlur = _ref.onBlur,
939
949
  onFocus = _ref.onFocus,
@@ -956,18 +966,18 @@
956
966
  return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
957
967
  };
958
968
  var row = options ? options.inline : false;
959
- var selectedIndex = utils.enumOptionsIndexForValue(value, enumOptions);
969
+ var selectedIndex = (_enumOptionsIndexForV = utils.enumOptionsIndexForValue(value, enumOptions)) != null ? _enumOptionsIndexForV : null;
960
970
  return jsxRuntime.jsxs(react.FormControl, _extends({
961
971
  mb: 1
962
972
  }, chakraProps, {
963
973
  isDisabled: disabled || readonly,
964
974
  isRequired: required,
965
975
  isReadOnly: readonly,
966
- children: [jsxRuntime.jsx(react.FormLabel, {
976
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
967
977
  htmlFor: id,
968
978
  id: id + "-label",
969
- children: label || schema.title
970
- }), jsxRuntime.jsx(react.RadioGroup, {
979
+ children: label
980
+ }), hideLabel || !label), jsxRuntime.jsx(react.RadioGroup, {
971
981
  onChange: _onChange,
972
982
  onBlur: _onBlur,
973
983
  onFocus: _onFocus,
@@ -1001,9 +1011,8 @@
1001
1011
  uiSchema = _ref.uiSchema,
1002
1012
  onChange = _ref.onChange,
1003
1013
  label = _ref.label,
1004
- id = _ref.id,
1005
- registry = _ref.registry;
1006
- var schemaUtils = registry.schemaUtils;
1014
+ hideLabel = _ref.hideLabel,
1015
+ id = _ref.id;
1007
1016
  var chakraProps = getChakra({
1008
1017
  uiSchema: uiSchema
1009
1018
  });
@@ -1012,7 +1021,6 @@
1012
1021
  label: label,
1013
1022
  id: id
1014
1023
  }, utils.rangeSpec(schema));
1015
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema) && (!!label || !!schema.title);
1016
1024
  var _onChange = function _onChange(value) {
1017
1025
  return onChange(value === undefined ? options.emptyValue : value);
1018
1026
  };
@@ -1027,10 +1035,10 @@
1027
1035
  return jsxRuntime.jsxs(react.FormControl, _extends({
1028
1036
  mb: 1
1029
1037
  }, chakraProps, {
1030
- children: [displayLabel ? jsxRuntime.jsx(react.FormLabel, {
1038
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
1031
1039
  htmlFor: id,
1032
- children: label || schema.title
1033
- }) : null, jsxRuntime.jsxs(react.Slider, _extends({}, sliderWidgetProps, {
1040
+ children: label
1041
+ }), hideLabel || !label), jsxRuntime.jsxs(react.Slider, _extends({}, sliderWidgetProps, {
1034
1042
  id: id,
1035
1043
  name: id,
1036
1044
  isDisabled: disabled || readonly,
@@ -1046,10 +1054,10 @@
1046
1054
  }
1047
1055
 
1048
1056
  function SelectWidget(props) {
1049
- var schema = props.schema,
1050
- id = props.id,
1057
+ var id = props.id,
1051
1058
  options = props.options,
1052
1059
  label = props.label,
1060
+ hideLabel = props.hideLabel,
1053
1061
  placeholder = props.placeholder,
1054
1062
  multiple = props.multiple,
1055
1063
  required = props.required,
@@ -1114,10 +1122,11 @@
1114
1122
  isRequired: required,
1115
1123
  isReadOnly: readonly,
1116
1124
  isInvalid: rawErrors && rawErrors.length > 0,
1117
- children: [(label || schema.title) && jsxRuntime.jsx(react.FormLabel, {
1118
- htmlFor: isMultiple ? undefined : id,
1119
- children: label || schema.title
1120
- }), jsxRuntime.jsx(chakraReactSelect.Select, {
1125
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
1126
+ htmlFor: id,
1127
+ id: id + "-label",
1128
+ children: label
1129
+ }), hideLabel || !label), jsxRuntime.jsx(chakraReactSelect.Select, {
1121
1130
  inputId: id,
1122
1131
  name: id,
1123
1132
  isMulti: isMultiple,
@@ -1139,6 +1148,7 @@
1139
1148
  placeholder = _ref.placeholder,
1140
1149
  value = _ref.value,
1141
1150
  label = _ref.label,
1151
+ hideLabel = _ref.hideLabel,
1142
1152
  disabled = _ref.disabled,
1143
1153
  autofocus = _ref.autofocus,
1144
1154
  readonly = _ref.readonly,
@@ -1146,16 +1156,12 @@
1146
1156
  onFocus = _ref.onFocus,
1147
1157
  onChange = _ref.onChange,
1148
1158
  options = _ref.options,
1149
- schema = _ref.schema,
1150
1159
  uiSchema = _ref.uiSchema,
1151
1160
  required = _ref.required,
1152
- rawErrors = _ref.rawErrors,
1153
- registry = _ref.registry;
1161
+ rawErrors = _ref.rawErrors;
1154
1162
  var chakraProps = getChakra({
1155
1163
  uiSchema: uiSchema
1156
1164
  });
1157
- var schemaUtils = registry.schemaUtils;
1158
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema) && (!!label || !!schema.title);
1159
1165
  var _onChange = function _onChange(_ref2) {
1160
1166
  var value = _ref2.target.value;
1161
1167
  return onChange(value === '' ? options.emptyValue : value);
@@ -1175,10 +1181,10 @@
1175
1181
  isRequired: required,
1176
1182
  isReadOnly: readonly,
1177
1183
  isInvalid: rawErrors && rawErrors.length > 0,
1178
- children: [displayLabel ? jsxRuntime.jsx(react.FormLabel, {
1184
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
1179
1185
  htmlFor: id,
1180
- children: label || schema.title
1181
- }) : null, jsxRuntime.jsx(react.Textarea, {
1186
+ children: label
1187
+ }), hideLabel || !label), jsxRuntime.jsx(react.Textarea, {
1182
1188
  id: id,
1183
1189
  name: id,
1184
1190
  value: value != null ? value : '',
@@ -1194,20 +1200,17 @@
1194
1200
 
1195
1201
  function UpDownWidget(props) {
1196
1202
  var id = props.id,
1197
- schema = props.schema,
1198
1203
  uiSchema = props.uiSchema,
1199
1204
  readonly = props.readonly,
1200
1205
  disabled = props.disabled,
1201
1206
  label = props.label,
1207
+ hideLabel = props.hideLabel,
1202
1208
  value = props.value,
1203
1209
  onChange = props.onChange,
1204
1210
  onBlur = props.onBlur,
1205
1211
  onFocus = props.onFocus,
1206
1212
  rawErrors = props.rawErrors,
1207
- required = props.required,
1208
- registry = props.registry;
1209
- var schemaUtils = registry.schemaUtils;
1210
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema) && (!!label || !!schema.title);
1213
+ required = props.required;
1211
1214
  var chakraProps = getChakra({
1212
1215
  uiSchema: uiSchema
1213
1216
  });
@@ -1229,10 +1232,10 @@
1229
1232
  isRequired: required,
1230
1233
  isReadOnly: readonly,
1231
1234
  isInvalid: rawErrors && rawErrors.length > 0,
1232
- children: [displayLabel ? jsxRuntime.jsx(react.FormLabel, {
1235
+ children: [utils.labelValue(jsxRuntime.jsx(react.FormLabel, {
1233
1236
  htmlFor: id,
1234
- children: label || schema.title
1235
- }) : null, jsxRuntime.jsxs(react.NumberInput, {
1237
+ children: label
1238
+ }), hideLabel || !label), jsxRuntime.jsxs(react.NumberInput, {
1236
1239
  value: value != null ? value : '',
1237
1240
  onChange: _onChange,
1238
1241
  onBlur: _onBlur,