@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "7.2.1",
3
+ "version": "7.3.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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 => setValue(e.target.value)}
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;