@thecb/components 8.4.10-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
@@ -27107,9 +27107,30 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
27107
27107
  ariaInvalid = _ref5.ariaInvalid,
27108
27108
  themeValues = _ref5.themeValues,
27109
27109
  index = _ref5.index,
27110
- defaultChecked = _ref5.defaultChecked,
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: 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,8 +49404,9 @@ var RadioGroup = function RadioGroup(_ref) {
49383
49404
  groupName: groupName,
49384
49405
  setValue: setValue,
49385
49406
  handleChange: handleChange,
49386
- "aria-invalid": field.dirty && field.hasErrors,
49387
- defaultChecked: field.rawValue
49407
+ field: field,
49408
+ config: config,
49409
+ "aria-invalid": field.dirty && field.hasErrors
49388
49410
  }));
49389
49411
  })));
49390
49412
  };