@rjsf/semantic-ui 5.0.0-beta.16 → 5.0.0-beta.18

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.
@@ -368,15 +368,16 @@ function BaseInputTemplate(props) {
368
368
  required: required,
369
369
  autoFocus: autofocus,
370
370
  disabled: disabled || readonly,
371
- list: schema.examples ? "examples_" + id : undefined
371
+ list: schema.examples ? utils.examplesId(id) : undefined
372
372
  }, semanticProps, {
373
373
  value: value || value === 0 ? value : "",
374
374
  error: rawErrors.length > 0,
375
375
  onChange: _onChange,
376
376
  onBlur: _onBlur,
377
- onFocus: _onFocus
377
+ onFocus: _onFocus,
378
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
378
379
  })), schema.examples && /*#__PURE__*/React__default["default"].createElement("datalist", {
379
- id: "examples_" + id
380
+ id: utils.examplesId(id)
380
381
  }, schema.examples.concat(schema["default"] ? [schema["default"]] : []).map(function (example) {
381
382
  return /*#__PURE__*/React__default["default"].createElement("option", {
382
383
  key: example,
@@ -513,7 +514,7 @@ function FieldHelpTemplate(props) {
513
514
  return null;
514
515
  }
515
516
 
516
- var _excluded = ["id", "children", "classNames", "displayLabel", "label", "errors", "help", "hidden", "rawDescription", "registry", "schema", "uiSchema"];
517
+ var _excluded = ["id", "children", "classNames", "style", "displayLabel", "label", "errors", "help", "hidden", "rawDescription", "registry", "schema", "uiSchema"];
517
518
  /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
518
519
  * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
519
520
  *
@@ -523,6 +524,7 @@ function FieldTemplate(props) {
523
524
  var id = props.id,
524
525
  children = props.children,
525
526
  classNames = props.classNames,
527
+ style = props.style,
526
528
  displayLabel = props.displayLabel,
527
529
  label = props.label,
528
530
  errors = props.errors,
@@ -548,6 +550,7 @@ function FieldTemplate(props) {
548
550
  }
549
551
  return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditionalTemplate, _extends({
550
552
  classNames: classNames,
553
+ style: style,
551
554
  id: id,
552
555
  label: label,
553
556
  registry: registry,
@@ -564,7 +567,7 @@ function FieldTemplate(props) {
564
567
  wrap: wrapLabel,
565
568
  className: "sui-field-label"
566
569
  }, rawDescription && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
567
- id: id + "-description",
570
+ id: utils.descriptionId(id),
568
571
  description: rawDescription,
569
572
  schema: schema,
570
573
  uiSchema: uiSchema,
@@ -599,14 +602,14 @@ function ObjectFieldTemplate(props) {
599
602
  var fieldTitle = uiOptions.title || title;
600
603
  var fieldDescription = uiOptions.description || description;
601
604
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, fieldTitle && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
602
- id: idSchema.$id + "-title",
605
+ id: utils.titleId(idSchema),
603
606
  title: fieldTitle,
604
607
  required: required,
605
608
  schema: schema,
606
609
  uiSchema: uiSchema,
607
610
  registry: registry
608
611
  }), fieldDescription && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
609
- id: idSchema.$id + "-description",
612
+ id: utils.descriptionId(idSchema),
610
613
  description: fieldDescription,
611
614
  schema: schema,
612
615
  uiSchema: uiSchema,
@@ -682,6 +685,7 @@ function TitleField(_ref) {
682
685
  function WrapIfAdditionalTemplate(props) {
683
686
  var children = props.children,
684
687
  classNames = props.classNames,
688
+ style = props.style,
685
689
  disabled = props.disabled,
686
690
  id = props.id,
687
691
  label = props.label,
@@ -702,7 +706,8 @@ function WrapIfAdditionalTemplate(props) {
702
706
  var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
703
707
  if (!additional) {
704
708
  return /*#__PURE__*/React__default["default"].createElement("div", {
705
- className: classNames
709
+ className: classNames,
710
+ style: style
706
711
  }, children);
707
712
  }
708
713
  var handleBlur = function handleBlur(_ref) {
@@ -711,6 +716,7 @@ function WrapIfAdditionalTemplate(props) {
711
716
  };
712
717
  return /*#__PURE__*/React__default["default"].createElement("div", {
713
718
  className: classNames,
719
+ style: style,
714
720
  key: id + "-key"
715
721
  }, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid, {
716
722
  columns: "equal"
@@ -825,24 +831,11 @@ function CheckboxWidget(props) {
825
831
  onBlur: _onBlur,
826
832
  onFocus: _onFocus,
827
833
  required: required,
828
- label: label || ""
834
+ label: label || "",
835
+ "aria-describedby": utils.ariaDescribedByIds(id)
829
836
  }));
830
837
  }
831
838
 
832
- function selectValue(value, selected, all) {
833
- var at = all.indexOf(value);
834
- var updated = selected.slice(0, at).concat(value, selected.slice(at));
835
- // As inserting values at predefined index positions doesn't work with empty
836
- // arrays, we need to reorder the updated selection to match the initial order
837
- return updated.sort(function (a, b) {
838
- return all.indexOf(a) > all.indexOf(b);
839
- });
840
- }
841
- function deselectValue(value, selected) {
842
- return selected.filter(function (v) {
843
- return v !== value;
844
- });
845
- }
846
839
  /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
847
840
  * It is typically used to represent an array of enums.
848
841
  *
@@ -868,6 +861,7 @@ function CheckboxesWidget(props) {
868
861
  var enumOptions = options.enumOptions,
869
862
  enumDisabled = options.enumDisabled,
870
863
  inline = options.inline;
864
+ var checkboxesValues = Array.isArray(value) ? value : [value];
871
865
  var title = schema.title;
872
866
  var semanticProps = getSemanticProps({
873
867
  options: options,
@@ -881,14 +875,10 @@ function CheckboxesWidget(props) {
881
875
  return function (_ref) {
882
876
  var checked = _ref.target.checked;
883
877
  // eslint-disable-next-line no-shadow
884
- var all = enumOptions ? enumOptions.map(function (_ref2) {
885
- var value = _ref2.value;
886
- return value;
887
- }) : [];
888
878
  if (checked) {
889
- onChange(selectValue(option.value, value, all));
879
+ onChange(utils.enumOptionsSelectValue(option.value, checkboxesValues, enumOptions));
890
880
  } else {
891
- onChange(deselectValue(option.value, value));
881
+ onChange(utils.enumOptionsDeselectValue(option.value, checkboxesValues));
892
882
  }
893
883
  };
894
884
  };
@@ -904,7 +894,7 @@ function CheckboxesWidget(props) {
904
894
  grouped: true
905
895
  };
906
896
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, title && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
907
- id: id + "-title",
897
+ id: utils.titleId(id),
908
898
  title: title,
909
899
  schema: schema,
910
900
  uiSchema: uiSchema,
@@ -913,10 +903,10 @@ function CheckboxesWidget(props) {
913
903
  id: id,
914
904
  name: id
915
905
  }, inlineOption), Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
916
- var checked = value.indexOf(option.value) !== -1;
906
+ var checked = checkboxesValues.includes(option.value);
917
907
  var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
918
908
  return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Checkbox, _extends({
919
- id: id + "-" + option.value,
909
+ id: utils.optionId(id, option),
920
910
  name: id,
921
911
  key: option.value,
922
912
  label: option.label
@@ -927,7 +917,8 @@ function CheckboxesWidget(props) {
927
917
  autoFocus: autofocus && index === 0,
928
918
  onChange: _onChange(option),
929
919
  onBlur: _onBlur,
930
- onFocus: _onFocus
920
+ onFocus: _onFocus,
921
+ "aria-describedby": utils.ariaDescribedByIds(id)
931
922
  }));
932
923
  })));
933
924
  }
@@ -980,7 +971,7 @@ function RadioWidget(props) {
980
971
  return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Field, _extends({
981
972
  required: required,
982
973
  control: semanticUiReact.Radio,
983
- id: id + "-" + option.value,
974
+ id: utils.optionId(id, option),
984
975
  name: id
985
976
  }, semanticProps, {
986
977
  onFocus: _onFocus,
@@ -991,7 +982,8 @@ function RadioWidget(props) {
991
982
  key: option.value,
992
983
  checked: value == option.value,
993
984
  onChange: _onChange,
994
- disabled: disabled || itemDisabled || readonly
985
+ disabled: disabled || itemDisabled || readonly,
986
+ "aria-describedby": utils.ariaDescribedByIds(id)
995
987
  }));
996
988
  }));
997
989
  }
@@ -1047,7 +1039,8 @@ function RangeWidget(props) {
1047
1039
  error: rawErrors.length > 0,
1048
1040
  onChange: _onChange,
1049
1041
  onBlur: _onBlur,
1050
- onFocus: _onFocus
1042
+ onFocus: _onFocus,
1043
+ "aria-describedby": utils.ariaDescribedByIds(id)
1051
1044
  })), /*#__PURE__*/React__default["default"].createElement("span", null, value));
1052
1045
  }
1053
1046
 
@@ -1141,7 +1134,8 @@ function SelectWidget(props) {
1141
1134
  options: dropdownOptions,
1142
1135
  onChange: _onChange,
1143
1136
  onBlur: _onBlur,
1144
- onFocus: _onFocus
1137
+ onFocus: _onFocus,
1138
+ "aria-describedby": utils.ariaDescribedByIds(id)
1145
1139
  }));
1146
1140
  }
1147
1141
 
@@ -1203,7 +1197,8 @@ function TextareaWidget(props) {
1203
1197
  rows: options.rows || 5,
1204
1198
  onChange: _onChange,
1205
1199
  onBlur: _onBlur,
1206
- onFocus: _onFocus
1200
+ onFocus: _onFocus,
1201
+ "aria-describedby": utils.ariaDescribedByIds(id)
1207
1202
  }));
1208
1203
  }
1209
1204