@thecb/components 8.4.9-beta.0 → 8.4.10-beta.1

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.
package/dist/index.cjs.js CHANGED
@@ -24235,8 +24235,7 @@ var FormSelect = function FormSelect(_ref) {
24235
24235
  variant: "pXS",
24236
24236
  weight: themeValues.fontWeight,
24237
24237
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
24238
- id: createIdFromString(labelTextWhenNoError, "error message"),
24239
- "aria-live": "polite"
24238
+ id: createIdFromString(labelTextWhenNoError, "error message")
24240
24239
  }, errorMessages[field.errors[0]]) : /*#__PURE__*/React__default.createElement(Text$1, {
24241
24240
  extraStyles: "height: ".concat(themeValues.lineHeight, ";")
24242
24241
  })));
@@ -27109,7 +27108,29 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
27109
27108
  themeValues = _ref5.themeValues,
27110
27109
  index = _ref5.index,
27111
27110
  _ref5$handleChange = _ref5.handleChange,
27112
- handleChange = _ref5$handleChange === void 0 ? noop : _ref5$handleChange;
27111
+ handleChange = _ref5$handleChange === void 0 ? noop : _ref5$handleChange,
27112
+ field = _ref5.field,
27113
+ config = _ref5.config;
27114
+
27115
+ var getDefaultChecked = function getDefaultChecked(value, idx) {
27116
+ var selectionExistsInConfig = config.map(function (c) {
27117
+ return c.value;
27118
+ }).includes(field.rawValue);
27119
+
27120
+ if (selectionExistsInConfig) {
27121
+ if (field.rawValue === value) {
27122
+ return true;
27123
+ }
27124
+ } else {
27125
+ if (idx === 0) {
27126
+ // fallback to first option as default selection
27127
+ return true;
27128
+ }
27129
+ }
27130
+
27131
+ return false;
27132
+ };
27133
+
27113
27134
  return /*#__PURE__*/React__default.createElement(InputAndLabelContainer, {
27114
27135
  align: "center",
27115
27136
  childGap: "0.5rem",
@@ -27127,7 +27148,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
27127
27148
  setValue(e.target.value);
27128
27149
  handleChange(e);
27129
27150
  },
27130
- defaultChecked: index === 0
27151
+ defaultChecked: getDefaultChecked(value, index)
27131
27152
  }), /*#__PURE__*/React__default.createElement(Text$1, {
27132
27153
  as: "label",
27133
27154
  htmlFor: id,
@@ -49383,6 +49404,8 @@ var RadioGroup = function RadioGroup(_ref) {
49383
49404
  groupName: groupName,
49384
49405
  setValue: setValue,
49385
49406
  handleChange: handleChange,
49407
+ field: field,
49408
+ config: config,
49386
49409
  "aria-invalid": field.dirty && field.hasErrors
49387
49410
  }));
49388
49411
  })));