@thecb/components 8.4.10-beta.0 → 8.4.10-beta.2

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,25 @@ 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 exists, selection comes from the redux-freeform state
27122
+ return field.rawValue === value;
27123
+ } // fallback to first option as default selection
27124
+
27125
+
27126
+ return idx === 0;
27127
+ };
27128
+
27113
27129
  return /*#__PURE__*/React__default.createElement(InputAndLabelContainer, {
27114
27130
  align: "center",
27115
27131
  childGap: "0.5rem",
@@ -27127,7 +27143,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
27127
27143
  setValue(e.target.value);
27128
27144
  handleChange(e);
27129
27145
  },
27130
- defaultChecked: defaultChecked || index === 0
27146
+ defaultChecked: getDefaultChecked(value, index)
27131
27147
  }), /*#__PURE__*/React__default.createElement(Text$1, {
27132
27148
  as: "label",
27133
27149
  htmlFor: id,
@@ -49383,8 +49399,9 @@ var RadioGroup = function RadioGroup(_ref) {
49383
49399
  groupName: groupName,
49384
49400
  setValue: setValue,
49385
49401
  handleChange: handleChange,
49386
- "aria-invalid": field.dirty && field.hasErrors,
49387
- defaultChecked: field.rawValue
49402
+ field: field,
49403
+ config: config,
49404
+ "aria-invalid": field.dirty && field.hasErrors
49388
49405
  }));
49389
49406
  })));
49390
49407
  };