@rjsf/semantic-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.
@@ -344,6 +344,7 @@ function BaseInputTemplate(props) {
344
344
  var id = props.id,
345
345
  placeholder = props.placeholder,
346
346
  label = props.label,
347
+ hideLabel = props.hideLabel,
347
348
  value = props.value,
348
349
  required = props.required,
349
350
  readonly = props.readonly,
@@ -358,7 +359,6 @@ function BaseInputTemplate(props) {
358
359
  uiSchema = props.uiSchema,
359
360
  formContext = props.formContext,
360
361
  type = props.type,
361
- registry = props.registry,
362
362
  _props$rawErrors = props.rawErrors,
363
363
  rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
364
364
  var inputProps = utils.getInputProps(schema, type, options);
@@ -367,7 +367,6 @@ function BaseInputTemplate(props) {
367
367
  formContext: formContext,
368
368
  options: options
369
369
  });
370
- var schemaUtils = registry.schemaUtils;
371
370
  var _onChange = function _onChange(_ref) {
372
371
  var value = _ref.target.value;
373
372
  return onChange(value === '' ? options.emptyValue : value);
@@ -378,14 +377,13 @@ function BaseInputTemplate(props) {
378
377
  var _onFocus = function _onFocus() {
379
378
  return onFocus && onFocus(id, value);
380
379
  };
381
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
382
380
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
383
381
  children: [jsxRuntime.jsx(semanticUiReact.Form.Input, _extends({
384
382
  id: id,
385
383
  name: id,
386
384
  placeholder: placeholder
387
385
  }, inputProps, {
388
- label: displayLabel ? label || schema.title : false,
386
+ label: utils.labelValue(label || undefined, hideLabel, false),
389
387
  required: required,
390
388
  autoFocus: autofocus,
391
389
  disabled: disabled || readonly,
@@ -647,19 +645,17 @@ function ObjectFieldTemplate(props) {
647
645
  var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
648
646
  // Button templates are not overridden in the uiSchema
649
647
  var AddButton = registry.templates.ButtonTemplates.AddButton;
650
- var fieldTitle = uiOptions.title || title;
651
- var fieldDescription = uiOptions.description || description;
652
648
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
653
- children: [fieldTitle && jsxRuntime.jsx(TitleFieldTemplate, {
649
+ children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
654
650
  id: utils.titleId(idSchema),
655
- title: fieldTitle,
651
+ title: title,
656
652
  required: required,
657
653
  schema: schema,
658
654
  uiSchema: uiSchema,
659
655
  registry: registry
660
- }), fieldDescription && jsxRuntime.jsx(DescriptionFieldTemplate, {
656
+ }), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
661
657
  id: utils.descriptionId(idSchema),
662
- description: fieldDescription,
658
+ description: description,
663
659
  schema: schema,
664
660
  uiSchema: uiSchema,
665
661
  registry: registry
@@ -851,11 +847,14 @@ var Templates = /*#__PURE__*/generateTemplates();
851
847
  * @param props - The `WidgetProps` for this component
852
848
  */
853
849
  function CheckboxWidget(props) {
850
+ var _options$description;
854
851
  var id = props.id,
855
852
  value = props.value,
856
853
  disabled = props.disabled,
857
854
  readonly = props.readonly,
858
- label = props.label,
855
+ _props$label = props.label,
856
+ label = _props$label === void 0 ? '' : _props$label,
857
+ hideLabel = props.hideLabel,
859
858
  autofocus = props.autofocus,
860
859
  onChange = props.onChange,
861
860
  onBlur = props.onBlur,
@@ -865,7 +864,8 @@ function CheckboxWidget(props) {
865
864
  schema = props.schema,
866
865
  uiSchema = props.uiSchema,
867
866
  _props$rawErrors = props.rawErrors,
868
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
867
+ rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
868
+ registry = props.registry;
869
869
  var semanticProps = getSemanticProps({
870
870
  options: options,
871
871
  formContext: formContext,
@@ -874,6 +874,7 @@ function CheckboxWidget(props) {
874
874
  inverted: 'false'
875
875
  }
876
876
  });
877
+ var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
877
878
  // Because an unchecked checkbox will cause html5 validation to fail, only add
878
879
  // the "required" attribute if the field value must be "true", due to the
879
880
  // "const" or "enum" keywords
@@ -888,21 +889,30 @@ function CheckboxWidget(props) {
888
889
  return onFocus && onFocus(id, value);
889
890
  };
890
891
  var checked = value == 'true' || value == true;
891
- return jsxRuntime.jsx(semanticUiReact.Form.Checkbox, _extends({
892
- id: id,
893
- name: id,
894
- disabled: disabled || readonly,
895
- autoFocus: autofocus
896
- }, semanticProps, {
897
- checked: typeof value === 'undefined' ? false : checked,
898
- error: rawErrors.length > 0,
899
- onChange: _onChange,
900
- onBlur: _onBlur,
901
- onFocus: _onFocus,
902
- required: required,
903
- label: label || '',
904
- "aria-describedby": utils.ariaDescribedByIds(id)
905
- }));
892
+ var description = (_options$description = options.description) != null ? _options$description : schema.description;
893
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
894
+ children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
895
+ id: utils.descriptionId(id),
896
+ description: description,
897
+ schema: schema,
898
+ uiSchema: uiSchema,
899
+ registry: registry
900
+ }), jsxRuntime.jsx(semanticUiReact.Form.Checkbox, _extends({
901
+ id: id,
902
+ name: id,
903
+ disabled: disabled || readonly,
904
+ autoFocus: autofocus
905
+ }, semanticProps, {
906
+ checked: typeof value === 'undefined' ? false : checked,
907
+ error: rawErrors.length > 0,
908
+ onChange: _onChange,
909
+ onBlur: _onBlur,
910
+ onFocus: _onFocus,
911
+ required: required,
912
+ label: utils.labelValue(label, hideLabel, false),
913
+ "aria-describedby": utils.ariaDescribedByIds(id)
914
+ }))]
915
+ });
906
916
  }
907
917
 
908
918
  /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
@@ -917,6 +927,8 @@ function CheckboxesWidget(props) {
917
927
  value = props.value,
918
928
  autofocus = props.autofocus,
919
929
  readonly = props.readonly,
930
+ label = props.label,
931
+ hideLabel = props.hideLabel,
920
932
  onChange = props.onChange,
921
933
  onBlur = props.onBlur,
922
934
  onFocus = props.onFocus,
@@ -931,7 +943,6 @@ function CheckboxesWidget(props) {
931
943
  enumDisabled = options.enumDisabled,
932
944
  inline = options.inline;
933
945
  var checkboxesValues = Array.isArray(value) ? value : [value];
934
- var title = schema.title;
935
946
  var semanticProps = getSemanticProps({
936
947
  options: options,
937
948
  formContext: formContext,
@@ -963,9 +974,9 @@ function CheckboxesWidget(props) {
963
974
  grouped: true
964
975
  };
965
976
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
966
- children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
977
+ children: [!hideLabel && !!label && jsxRuntime.jsx(TitleFieldTemplate, {
967
978
  id: utils.titleId(id),
968
- title: title,
979
+ title: label,
969
980
  schema: schema,
970
981
  uiSchema: uiSchema,
971
982
  registry: registry
@@ -1147,12 +1158,12 @@ function createDefaultValueOptionsForDropDown(enumOptions, enumDisabled) {
1147
1158
  * @param props - The `WidgetProps` for this component
1148
1159
  */
1149
1160
  function SelectWidget(props) {
1150
- var schema = props.schema,
1151
- uiSchema = props.uiSchema,
1161
+ var uiSchema = props.uiSchema,
1152
1162
  formContext = props.formContext,
1153
1163
  id = props.id,
1154
1164
  options = props.options,
1155
1165
  label = props.label,
1166
+ hideLabel = props.hideLabel,
1156
1167
  required = props.required,
1157
1168
  disabled = props.disabled,
1158
1169
  readonly = props.readonly,
@@ -1199,7 +1210,7 @@ function SelectWidget(props) {
1199
1210
  return jsxRuntime.jsx(semanticUiReact.Form.Dropdown, _extends({
1200
1211
  id: id,
1201
1212
  name: id,
1202
- label: label || schema.title,
1213
+ label: utils.labelValue(label || undefined, hideLabel, false),
1203
1214
  multiple: typeof multiple === 'undefined' ? false : multiple,
1204
1215
  value: typeof value === 'undefined' ? emptyValue : selectedIndexes,
1205
1216
  error: rawErrors.length > 0,
@@ -1229,15 +1240,13 @@ function TextareaWidget(props) {
1229
1240
  disabled = props.disabled,
1230
1241
  autofocus = props.autofocus,
1231
1242
  label = props.label,
1243
+ hideLabel = props.hideLabel,
1232
1244
  readonly = props.readonly,
1233
1245
  onBlur = props.onBlur,
1234
1246
  onFocus = props.onFocus,
1235
1247
  onChange = props.onChange,
1236
1248
  options = props.options,
1237
- schema = props.schema,
1238
- uiSchema = props.uiSchema,
1239
1249
  formContext = props.formContext,
1240
- registry = props.registry,
1241
1250
  _props$rawErrors = props.rawErrors,
1242
1251
  rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
1243
1252
  var semanticProps = getSemanticProps({
@@ -1247,7 +1256,6 @@ function TextareaWidget(props) {
1247
1256
  inverted: 'false'
1248
1257
  }
1249
1258
  });
1250
- var schemaUtils = registry.schemaUtils;
1251
1259
  // eslint-disable-next-line no-shadow
1252
1260
  var _onChange = function _onChange(_ref) {
1253
1261
  var value = _ref.target.value;
@@ -1259,11 +1267,10 @@ function TextareaWidget(props) {
1259
1267
  var _onFocus = function _onFocus() {
1260
1268
  return onFocus && onFocus(id, value);
1261
1269
  };
1262
- var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
1263
1270
  return jsxRuntime.jsx(semanticUiReact.Form.TextArea, _extends({
1264
1271
  id: id,
1265
1272
  name: id,
1266
- label: displayLabel ? label || schema.title : false,
1273
+ label: utils.labelValue(label || undefined, hideLabel, false),
1267
1274
  placeholder: placeholder,
1268
1275
  autoFocus: autofocus,
1269
1276
  required: required,