@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 +22 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +22 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +49 -34
- package/src/components/molecules/radio-group/RadioGroup.js +2 -1
- package/src/components/molecules/radio-group/RadioGroup.stories.js +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -27099,9 +27099,25 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
|
27099
27099
|
ariaInvalid = _ref5.ariaInvalid,
|
|
27100
27100
|
themeValues = _ref5.themeValues,
|
|
27101
27101
|
index = _ref5.index,
|
|
27102
|
-
defaultChecked = _ref5.defaultChecked,
|
|
27103
27102
|
_ref5$handleChange = _ref5.handleChange,
|
|
27104
|
-
handleChange = _ref5$handleChange === void 0 ? noop : _ref5$handleChange
|
|
27103
|
+
handleChange = _ref5$handleChange === void 0 ? noop : _ref5$handleChange,
|
|
27104
|
+
field = _ref5.field,
|
|
27105
|
+
config = _ref5.config;
|
|
27106
|
+
|
|
27107
|
+
var getDefaultChecked = function getDefaultChecked(value, idx) {
|
|
27108
|
+
var selectionExistsInConfig = config.map(function (c) {
|
|
27109
|
+
return c.value;
|
|
27110
|
+
}).includes(field.rawValue);
|
|
27111
|
+
|
|
27112
|
+
if (selectionExistsInConfig) {
|
|
27113
|
+
// if exists, selection comes from the redux-freeform state
|
|
27114
|
+
return field.rawValue === value;
|
|
27115
|
+
} // fallback to first option as default selection
|
|
27116
|
+
|
|
27117
|
+
|
|
27118
|
+
return idx === 0;
|
|
27119
|
+
};
|
|
27120
|
+
|
|
27105
27121
|
return /*#__PURE__*/React.createElement(InputAndLabelContainer, {
|
|
27106
27122
|
align: "center",
|
|
27107
27123
|
childGap: "0.5rem",
|
|
@@ -27119,7 +27135,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
|
27119
27135
|
setValue(e.target.value);
|
|
27120
27136
|
handleChange(e);
|
|
27121
27137
|
},
|
|
27122
|
-
defaultChecked:
|
|
27138
|
+
defaultChecked: getDefaultChecked(value, index)
|
|
27123
27139
|
}), /*#__PURE__*/React.createElement(Text$1, {
|
|
27124
27140
|
as: "label",
|
|
27125
27141
|
htmlFor: id,
|
|
@@ -49375,8 +49391,9 @@ var RadioGroup = function RadioGroup(_ref) {
|
|
|
49375
49391
|
groupName: groupName,
|
|
49376
49392
|
setValue: setValue,
|
|
49377
49393
|
handleChange: handleChange,
|
|
49378
|
-
|
|
49379
|
-
|
|
49394
|
+
field: field,
|
|
49395
|
+
config: config,
|
|
49396
|
+
"aria-invalid": field.dirty && field.hasErrors
|
|
49380
49397
|
}));
|
|
49381
49398
|
})));
|
|
49382
49399
|
};
|