@thecb/components 8.4.8 → 8.4.9
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 +116 -114
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +116 -114
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +49 -33
- package/src/components/molecules/radio-group/RadioGroup.js +2 -0
- package/src/components/molecules/radio-group/RadioGroup.stories.js +1 -1
- package/src/types/common/Field.ts +3 -3
- /package/src/components/atoms/icons/{ExternalLinkicon.js → ExternalLinkIcon.js} +0 -0
package/package.json
CHANGED
|
@@ -57,30 +57,45 @@ const RadioButtonWithLabel = ({
|
|
|
57
57
|
ariaInvalid,
|
|
58
58
|
themeValues,
|
|
59
59
|
index,
|
|
60
|
-
handleChange = noop // optional, for custom event handling in ingesting app
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
handleChange = noop, // optional, for custom event handling in ingesting app
|
|
61
|
+
field,
|
|
62
|
+
config
|
|
63
|
+
}) => {
|
|
64
|
+
const getDefaultChecked = (value, idx) => {
|
|
65
|
+
const selectionExistsInConfig = config
|
|
66
|
+
.map(c => c.value)
|
|
67
|
+
.includes(field.rawValue);
|
|
68
|
+
|
|
69
|
+
if (selectionExistsInConfig) {
|
|
70
|
+
// if exists, selection comes from the redux-freeform state
|
|
71
|
+
return field.rawValue === value;
|
|
72
|
+
}
|
|
73
|
+
// fallback to first option as default selection
|
|
74
|
+
return idx === 0;
|
|
75
|
+
};
|
|
76
|
+
return (
|
|
77
|
+
<InputAndLabelContainer
|
|
78
|
+
align="center"
|
|
79
|
+
childGap="0.5rem"
|
|
80
|
+
activeColor={themeValues.activeColor}
|
|
81
|
+
>
|
|
82
|
+
<HiddenRadioInput
|
|
83
|
+
aria-invalid={ariaInvalid}
|
|
84
|
+
style={{ marginTop: 0 }}
|
|
85
|
+
type="radio"
|
|
86
|
+
name={groupName}
|
|
87
|
+
id={id}
|
|
88
|
+
value={value}
|
|
89
|
+
onChange={e => {
|
|
90
|
+
setValue(e.target.value);
|
|
91
|
+
handleChange(e);
|
|
92
|
+
}}
|
|
93
|
+
defaultChecked={getDefaultChecked(value, index)}
|
|
94
|
+
/>
|
|
95
|
+
<Text
|
|
96
|
+
as="label"
|
|
97
|
+
htmlFor={id}
|
|
98
|
+
extraStyles={`
|
|
84
99
|
font-size: 1rem;
|
|
85
100
|
display: flex;
|
|
86
101
|
width: 100%;
|
|
@@ -88,15 +103,16 @@ const RadioButtonWithLabel = ({
|
|
|
88
103
|
cursor: pointer;
|
|
89
104
|
}
|
|
90
105
|
`}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
106
|
+
>
|
|
107
|
+
<Circle
|
|
108
|
+
activeColor={themeValues.activeColor}
|
|
109
|
+
inactiveBorderColor={themeValues.inactiveBorderColor}
|
|
110
|
+
/>
|
|
111
|
+
{labelText}
|
|
112
|
+
</Text>
|
|
113
|
+
</InputAndLabelContainer>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
100
116
|
|
|
101
117
|
export default themeComponent(
|
|
102
118
|
RadioButtonWithLabel,
|
|
File without changes
|