@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 +27 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +27 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +53 -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,30 @@ 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 (field.rawValue === value) {
|
|
27114
|
+
return true;
|
|
27115
|
+
}
|
|
27116
|
+
} else {
|
|
27117
|
+
if (idx === 0) {
|
|
27118
|
+
// fallback to first option as default selection
|
|
27119
|
+
return true;
|
|
27120
|
+
}
|
|
27121
|
+
}
|
|
27122
|
+
|
|
27123
|
+
return false;
|
|
27124
|
+
};
|
|
27125
|
+
|
|
27105
27126
|
return /*#__PURE__*/React.createElement(InputAndLabelContainer, {
|
|
27106
27127
|
align: "center",
|
|
27107
27128
|
childGap: "0.5rem",
|
|
@@ -27119,7 +27140,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
|
27119
27140
|
setValue(e.target.value);
|
|
27120
27141
|
handleChange(e);
|
|
27121
27142
|
},
|
|
27122
|
-
defaultChecked:
|
|
27143
|
+
defaultChecked: getDefaultChecked(value, index)
|
|
27123
27144
|
}), /*#__PURE__*/React.createElement(Text$1, {
|
|
27124
27145
|
as: "label",
|
|
27125
27146
|
htmlFor: id,
|
|
@@ -49375,8 +49396,9 @@ var RadioGroup = function RadioGroup(_ref) {
|
|
|
49375
49396
|
groupName: groupName,
|
|
49376
49397
|
setValue: setValue,
|
|
49377
49398
|
handleChange: handleChange,
|
|
49378
|
-
|
|
49379
|
-
|
|
49399
|
+
field: field,
|
|
49400
|
+
config: config,
|
|
49401
|
+
"aria-invalid": field.dirty && field.hasErrors
|
|
49380
49402
|
}));
|
|
49381
49403
|
})));
|
|
49382
49404
|
};
|