@rjsf/chakra-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.
@@ -252,9 +252,10 @@ function BaseInputTemplate(props) {
252
252
  autoFocus: autofocus,
253
253
  placeholder: placeholder
254
254
  }, inputProps, {
255
- list: schema.examples ? "examples_" + id : undefined
255
+ list: schema.examples ? utils.examplesId(id) : undefined,
256
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
256
257
  })), schema.examples ? React__namespace.createElement("datalist", {
257
- id: "examples_" + id
258
+ id: utils.examplesId(id)
258
259
  }, schema.examples.concat(schema["default"] ? [schema["default"]] : []).map(function (example) {
259
260
  return React__namespace.createElement("option", {
260
261
  key: example,
@@ -342,7 +343,7 @@ function FieldErrorTemplate(props) {
342
343
  if (errors.length === 0) {
343
344
  return null;
344
345
  }
345
- var id = idSchema.$id + "__error";
346
+ var id = utils.errorId(idSchema);
346
347
  return React__default["default"].createElement(react.List, null, errors.map(function (error, i) {
347
348
  return React__default["default"].createElement(react.ListItem, {
348
349
  key: i
@@ -362,7 +363,7 @@ function FieldHelpTemplate(props) {
362
363
  if (!help) {
363
364
  return null;
364
365
  }
365
- var id = idSchema.$id + "__help";
366
+ var id = utils.helpId(idSchema);
366
367
  return React__default["default"].createElement(react.FormHelperText, {
367
368
  id: id
368
369
  }, help);
@@ -372,6 +373,7 @@ function FieldTemplate(props) {
372
373
  var id = props.id,
373
374
  children = props.children,
374
375
  classNames = props.classNames,
376
+ style = props.style,
375
377
  disabled = props.disabled,
376
378
  displayLabel = props.displayLabel,
377
379
  hidden = props.hidden,
@@ -399,6 +401,7 @@ function FieldTemplate(props) {
399
401
  }
400
402
  return React__default["default"].createElement(WrapIfAdditionalTemplate, {
401
403
  classNames: classNames,
404
+ style: style,
402
405
  disabled: disabled,
403
406
  id: id,
404
407
  label: label,
@@ -436,14 +439,14 @@ function ObjectFieldTemplate(props) {
436
439
  // Button templates are not overridden in the uiSchema
437
440
  var AddButton = registry.templates.ButtonTemplates.AddButton;
438
441
  return React__default["default"].createElement(React__default["default"].Fragment, null, (uiOptions.title || title) && React__default["default"].createElement(TitleFieldTemplate, {
439
- id: idSchema.$id + "-title",
442
+ id: utils.titleId(idSchema),
440
443
  title: uiOptions.title || title,
441
444
  required: required,
442
445
  schema: schema,
443
446
  uiSchema: uiSchema,
444
447
  registry: registry
445
448
  }), (uiOptions.description || description) && React__default["default"].createElement(DescriptionFieldTemplate, {
446
- id: idSchema.$id + "-description",
449
+ id: utils.descriptionId(idSchema),
447
450
  description: uiOptions.description || description,
448
451
  schema: schema,
449
452
  uiSchema: uiSchema,
@@ -498,6 +501,7 @@ function TitleField(_ref) {
498
501
  function WrapIfAdditionalTemplate(props) {
499
502
  var children = props.children,
500
503
  classNames = props.classNames,
504
+ style = props.style,
501
505
  disabled = props.disabled,
502
506
  id = props.id,
503
507
  label = props.label,
@@ -513,7 +517,8 @@ function WrapIfAdditionalTemplate(props) {
513
517
  var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
514
518
  if (!additional) {
515
519
  return React__default["default"].createElement("div", {
516
- className: classNames
520
+ className: classNames,
521
+ style: style
517
522
  }, children);
518
523
  }
519
524
  var keyLabel = label + " Key";
@@ -524,6 +529,7 @@ function WrapIfAdditionalTemplate(props) {
524
529
  return React__default["default"].createElement(react.Grid, {
525
530
  key: id + "-key",
526
531
  className: classNames,
532
+ style: style,
527
533
  alignItems: "center",
528
534
  gap: 2
529
535
  }, React__default["default"].createElement(react.GridItem, null, React__default["default"].createElement(react.FormControl, {
@@ -597,7 +603,8 @@ function DateElement(props) {
597
603
  schema: {
598
604
  type: "integer"
599
605
  },
600
- value: value
606
+ value: value,
607
+ "aria-describedby": utils.ariaDescribedByIds(props.name)
601
608
  }));
602
609
  }
603
610
  var readyForChange = function readyForChange(state) {
@@ -781,7 +788,8 @@ function CheckboxWidget(props) {
781
788
  isDisabled: disabled || readonly,
782
789
  onChange: _onChange,
783
790
  onBlur: _onBlur,
784
- onFocus: _onFocus
791
+ onFocus: _onFocus,
792
+ "aria-describedby": utils.ariaDescribedByIds(id)
785
793
  }, label && React__default["default"].createElement(react.Text, null, label)));
786
794
  }
787
795
 
@@ -805,6 +813,7 @@ function CheckboxesWidget(props) {
805
813
  var chakraProps = getChakra({
806
814
  uiSchema: uiSchema
807
815
  });
816
+ var checkboxesValues = Array.isArray(value) ? value : [value];
808
817
  var _onBlur = function _onBlur(_ref) {
809
818
  var value = _ref.target.value;
810
819
  return onBlur(id, value);
@@ -828,15 +837,16 @@ function CheckboxesWidget(props) {
828
837
  onChange: function onChange(option) {
829
838
  return _onChange(option);
830
839
  },
831
- defaultValue: value
840
+ defaultValue: value,
841
+ "aria-describedby": utils.ariaDescribedByIds(id)
832
842
  }, React__default["default"].createElement(react.Stack, {
833
843
  direction: row ? "row" : "column"
834
844
  }, Array.isArray(enumOptions) && enumOptions.map(function (option) {
835
- var checked = value.indexOf(option.value) !== -1;
845
+ var checked = checkboxesValues.includes(option.value);
836
846
  var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
837
847
  return React__default["default"].createElement(react.Checkbox, {
838
848
  key: option.value,
839
- id: id + "-" + option.value,
849
+ id: utils.optionId(id, option),
840
850
  name: id,
841
851
  value: option.value,
842
852
  isChecked: checked,
@@ -888,7 +898,8 @@ function RadioWidget(_ref) {
888
898
  onBlur: _onBlur,
889
899
  onFocus: _onFocus,
890
900
  value: "" + value,
891
- name: id
901
+ name: id,
902
+ "aria-describedby": utils.ariaDescribedByIds(id)
892
903
  }, React__default["default"].createElement(react.Stack, {
893
904
  direction: row ? "row" : "column"
894
905
  }, Array.isArray(enumOptions) && enumOptions.map(function (option) {
@@ -896,7 +907,7 @@ function RadioWidget(_ref) {
896
907
  return React__default["default"].createElement(react.Radio, {
897
908
  value: "" + option.value,
898
909
  key: option.value,
899
- id: id + "-" + option.value,
910
+ id: utils.optionId(id, option),
900
911
  disabled: disabled || itemDisabled || readonly
901
912
  }, "" + option.label);
902
913
  }))));
@@ -946,7 +957,8 @@ function RangeWidget(_ref) {
946
957
  isDisabled: disabled || readonly,
947
958
  onChange: _onChange,
948
959
  onBlur: _onBlur,
949
- onFocus: _onFocus
960
+ onFocus: _onFocus,
961
+ "aria-describedby": utils.ariaDescribedByIds(id)
950
962
  }), React__default["default"].createElement(react.SliderTrack, null, React__default["default"].createElement(react.SliderFilledTrack, null)), React__default["default"].createElement(react.SliderThumb, null)));
951
963
  }
952
964
 
@@ -1026,7 +1038,8 @@ function SelectWidget(props) {
1026
1038
  onChange: isMultiple ? _onMultiChange : _onChange,
1027
1039
  onFocus: _onFocus,
1028
1040
  autoFocus: autofocus,
1029
- value: formValue
1041
+ value: formValue,
1042
+ "aria-describedby": utils.ariaDescribedByIds(id)
1030
1043
  }));
1031
1044
  }
1032
1045
 
@@ -1081,7 +1094,8 @@ function TextareaWidget(_ref) {
1081
1094
  autoFocus: autofocus,
1082
1095
  onChange: _onChange,
1083
1096
  onBlur: _onBlur,
1084
- onFocus: _onFocus
1097
+ onFocus: _onFocus,
1098
+ "aria-describedby": utils.ariaDescribedByIds(id)
1085
1099
  }));
1086
1100
  }
1087
1101
 
@@ -1128,7 +1142,8 @@ function UpDownWidget(props) {
1128
1142
  value: value != null ? value : "",
1129
1143
  onChange: _onChange,
1130
1144
  onBlur: _onBlur,
1131
- onFocus: _onFocus
1145
+ onFocus: _onFocus,
1146
+ "aria-describedby": utils.ariaDescribedByIds(id)
1132
1147
  }, React__default["default"].createElement(react.NumberInputField, {
1133
1148
  id: id,
1134
1149
  name: id