@thecb/components 7.2.1 → 7.3.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 +8 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +8 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +7 -2
- package/src/components/molecules/radio-group/RadioGroup.js +3 -0
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.stories.js +0 -39
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { Cluster } from "../../atoms/layouts";
|
|
|
3
3
|
import Text from "../text";
|
|
4
4
|
import styled from "styled-components";
|
|
5
5
|
import { colors } from "../../../constants";
|
|
6
|
+
import { noop } from "../../../util/general";
|
|
6
7
|
|
|
7
8
|
const HiddenRadioInput = styled.input`
|
|
8
9
|
// can still select the element with the keyboard, but it's invisible and doesn't interfere with the spacing of other elements around it
|
|
@@ -53,7 +54,8 @@ const RadioButtonWithLabel = ({
|
|
|
53
54
|
groupName,
|
|
54
55
|
setValue,
|
|
55
56
|
ariaInvalid,
|
|
56
|
-
index
|
|
57
|
+
index,
|
|
58
|
+
handleChange = noop // optional, for custom event handling in ingesting app
|
|
57
59
|
}) => (
|
|
58
60
|
<InputAndLabelContainer align="center" childGap="0.5rem">
|
|
59
61
|
<HiddenRadioInput
|
|
@@ -63,7 +65,10 @@ const RadioButtonWithLabel = ({
|
|
|
63
65
|
name={groupName}
|
|
64
66
|
id={id}
|
|
65
67
|
value={value}
|
|
66
|
-
onChange={e =>
|
|
68
|
+
onChange={e => {
|
|
69
|
+
setValue(e.target.value);
|
|
70
|
+
handleChange(e);
|
|
71
|
+
}}
|
|
67
72
|
defaultChecked={index === 0}
|
|
68
73
|
/>
|
|
69
74
|
<Text
|
|
@@ -3,6 +3,7 @@ import RadioButtonWithLabel from "../../atoms/radio-button-with-label/RadioButto
|
|
|
3
3
|
import { Stack } from "../../atoms";
|
|
4
4
|
import { colors } from "../../../constants";
|
|
5
5
|
import styled from "styled-components";
|
|
6
|
+
import { noop } from "../../../util/general";
|
|
6
7
|
|
|
7
8
|
const DefaultHeading = styled.div`
|
|
8
9
|
font-size: 0.875rem;
|
|
@@ -25,6 +26,7 @@ const RadioGroup = ({
|
|
|
25
26
|
),
|
|
26
27
|
config,
|
|
27
28
|
extraStyles,
|
|
29
|
+
handleChange = noop, // optional, for custom event handling in ingesting app
|
|
28
30
|
// redux-freeform props - this is similar to how FormInput works, duplicated because the radio input is hidden for styling overrides
|
|
29
31
|
field,
|
|
30
32
|
fieldActions
|
|
@@ -45,6 +47,7 @@ const RadioGroup = ({
|
|
|
45
47
|
{...c}
|
|
46
48
|
groupName={groupName}
|
|
47
49
|
setValue={setValue}
|
|
50
|
+
handleChange={handleChange}
|
|
48
51
|
aria-invalid={
|
|
49
52
|
(field.dirty && field.hasErrors) ||
|
|
50
53
|
(field.hasErrors && showErrors)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import RadioButtonWithLabel from "./RadioButtonWithLabel";
|
|
3
|
-
import { Box } from "../layouts";
|
|
4
|
-
import page from "../../../../.storybook/page";
|
|
5
|
-
|
|
6
|
-
export const radioButtonWithLabel = () => {
|
|
7
|
-
const [selected, setSelected] = useState("");
|
|
8
|
-
const handleRadioClick = e => {
|
|
9
|
-
setSelected(e.currentTarget.value);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<Box>
|
|
14
|
-
<RadioButtonWithLabel
|
|
15
|
-
id="some-id"
|
|
16
|
-
value="some-value"
|
|
17
|
-
labelText="A radio button with a label."
|
|
18
|
-
handleRadioClick={handleRadioClick}
|
|
19
|
-
selected={selected}
|
|
20
|
-
/>
|
|
21
|
-
<RadioButtonWithLabel
|
|
22
|
-
id="another-id"
|
|
23
|
-
value="another-value"
|
|
24
|
-
labelText="Another radio button with a label."
|
|
25
|
-
handleRadioClick={handleRadioClick}
|
|
26
|
-
selected={selected}
|
|
27
|
-
/>
|
|
28
|
-
</Box>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
radioButtonWithLabel.storyName = "RadioButtonWithLabel";
|
|
33
|
-
|
|
34
|
-
const story = page({
|
|
35
|
-
title: "Components|Atoms/RadioButtonWithLabel",
|
|
36
|
-
Component: RadioButtonWithLabel
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export default story;
|