@thecb/components 9.5.2-beta.0 → 9.5.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.
Files changed (30) hide show
  1. package/dist/index.cjs.js +3254 -3110
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.esm.js +3254 -3111
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/atoms/icons/MultiCartIcon.d.ts +1 -0
  8. package/src/components/atoms/icons/MultiCartIcon.js +26 -0
  9. package/src/components/atoms/icons/icons.stories.js +3 -1
  10. package/src/components/atoms/icons/index.d.ts +1 -0
  11. package/src/components/atoms/icons/index.js +3 -1
  12. package/src/components/atoms/jumbo/Jumbo.js +7 -1
  13. package/src/components/atoms/labeled-amount/LabeledAmount.js +7 -32
  14. package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +13 -0
  15. package/src/components/atoms/labeled-amount/LabeledAmount.theme.js +7 -1
  16. package/src/components/atoms/labeled-amount/LabeledAmountV1.js +37 -0
  17. package/src/components/atoms/labeled-amount/LabeledAmountV2.js +34 -0
  18. package/src/components/atoms/line-item/LineItem.js +21 -35
  19. package/src/components/atoms/line-item/LineItem.theme.js +2 -2
  20. package/src/components/atoms/searchable-select/SearchableSelect.js +15 -7
  21. package/src/components/atoms/searchable-select/SearchableSelect.stories.js +5 -4
  22. package/src/components/molecules/modal/Modal.js +3 -3
  23. package/src/components/molecules/partial-amount-form/PartialAmountForm.js +8 -2
  24. package/src/components/molecules/payment-details/PaymentDetails.js +14 -13
  25. package/src/components/molecules/payment-details/PaymentDetails.stories.js +36 -0
  26. package/src/components/molecules/payment-details/PaymentDetails.theme.js +2 -2
  27. package/src/components/molecules/radio-section/InnerRadioSection.js +210 -0
  28. package/src/components/molecules/radio-section/RadioSection.js +87 -210
  29. package/src/components/molecules/radio-section/RadioSection.stories.js +92 -15
  30. package/src/components/molecules/radio-section/RadioSection.theme.js +2 -2
@@ -0,0 +1,210 @@
1
+ import React, { Fragment } from "react";
2
+ import styled from "styled-components";
3
+ import { AnimatePresence } from "framer-motion";
4
+ import RadioButton from "./radio-button/RadioButton";
5
+ import { Box, Cluster, Stack, Motion } from "../../atoms/layouts";
6
+ import { createIdFromString, noop } from "../../../util/general";
7
+ import Text from "../../atoms/text";
8
+ import { CHARADE_GREY } from "../../../constants/colors";
9
+ import { MANATEE_GREY } from "../../../constants/colors";
10
+
11
+ const idString = section =>
12
+ typeof section.title === "string"
13
+ ? createIdFromString(section.title)
14
+ : section.id;
15
+
16
+ const InnerRadioSection = ({
17
+ themeValues,
18
+ isMobile,
19
+ supportsTouch,
20
+ section,
21
+ sectionIndex,
22
+ openSection = "",
23
+ toggleOpenSection,
24
+ staggeredAnimation = false,
25
+ initiallyOpen = true,
26
+ openHeight = "auto",
27
+ ariaDescribedBy,
28
+ focused,
29
+ setFocused,
30
+ sectionRefs,
31
+ ariaLabelledBy,
32
+ isLastGroupedItemInSection,
33
+ onKeyDown = noop
34
+ }) => {
35
+ const wrapper = {
36
+ open: {
37
+ height: openHeight,
38
+ opacity: 1,
39
+ transition: {
40
+ duration: 0.3,
41
+ ease: [0.04, 0.62, 0.23, 0.98],
42
+ staggerChildren: staggeredAnimation ? 0.15 : 0
43
+ }
44
+ },
45
+ closed: {
46
+ height: 0,
47
+ opacity: 0,
48
+ transition: {
49
+ duration: 0.3,
50
+ ease: [0.04, 0.62, 0.23, 0.98],
51
+ staggerChildren: staggeredAnimation ? 0.15 : 0,
52
+ staggerDirection: -1
53
+ }
54
+ }
55
+ };
56
+
57
+ const borderStyles = `
58
+ border-width: 0 0 1px 0;
59
+ border-color: ${
60
+ isLastGroupedItemInSection ? MANATEE_GREY : themeValues.borderColor
61
+ };
62
+ border-style: solid;
63
+ border-radius: 0px;
64
+ transform-origin: 100% 0;
65
+
66
+ &:last-child {
67
+ border-width: 0;
68
+ }
69
+ `;
70
+
71
+ const RightIcon = styled.img`
72
+ height: ${({ isMobile }) => (isMobile ? "14px" : "18px")};
73
+ width: ${({ isMobile }) => (isMobile ? "22px" : "28px")};
74
+ ${({ fade }) => fade && "opacity: 0.4;"}
75
+ transition: opacity 0.3s ease;
76
+ `;
77
+
78
+ return (
79
+ <Motion
80
+ tabIndex={section.hideRadioButton || section.disabled ? "-1" : "0"}
81
+ ref={sectionRefs.current[sectionIndex]}
82
+ onBlur={() => !section.disabled && setFocused(null)}
83
+ onFocus={() => !section.disabled && setFocused(section.id)}
84
+ onKeyDown={onKeyDown}
85
+ hoverStyles={themeValues.focusStyles}
86
+ animate={openSection === section.id ? "open" : "closed"}
87
+ initial={initiallyOpen ? "open" : "closed"}
88
+ key={`item-${section.id}`}
89
+ extraStyles={borderStyles}
90
+ role="radio"
91
+ aria-checked={openSection === section.id}
92
+ aria-disabled={section.disabled}
93
+ aria-required={section.required}
94
+ aria-labelledby={ariaLabelledBy}
95
+ aria-describedby={ariaDescribedBy}
96
+ onClick={
97
+ (isMobile && supportsTouch) || section.disabled
98
+ ? noop
99
+ : () => toggleOpenSection(section.id)
100
+ }
101
+ onTouchEnd={
102
+ isMobile && supportsTouch && !section.disabled
103
+ ? () => toggleOpenSection(section.id)
104
+ : noop
105
+ }
106
+ id={`inner-radio-section-${sectionIndex}`}
107
+ data-qa={
108
+ section.dataQa
109
+ ? section.dataQa
110
+ : section.id || `inner-radio-section-${sectionIndex}`
111
+ }
112
+ >
113
+ <Stack childGap="0">
114
+ <Box
115
+ padding={section.hideRadioButton ? "1.5rem" : "1.25rem 1.5rem"}
116
+ background={
117
+ section.disabled
118
+ ? themeValues.headingDisabledColor
119
+ : themeValues.headingBackgroundColor
120
+ }
121
+ key={`header-${section.id}`}
122
+ borderSize="0px"
123
+ borderColor={themeValues.borderColor}
124
+ borderWidthOverride={
125
+ openSection === section.id && !!section.content
126
+ ? `0px 0px 1px 0px`
127
+ : ``
128
+ }
129
+ extraStyles={!section.disabled ? "cursor: pointer;" : ""}
130
+ >
131
+ <Cluster justify="space-between" align="center" childGap="1px" nowrap>
132
+ <Cluster justify="flex-start" align="center" nowrap>
133
+ {!section.hideRadioButton && (
134
+ <Box padding="0">
135
+ <RadioButton
136
+ id={`radio-input-${idString(section)}`}
137
+ name={idString(section)}
138
+ ariaDescribedBy={ariaDescribedBy}
139
+ radioOn={openSection === section.id}
140
+ radioFocused={focused === section.id}
141
+ toggleRadio={
142
+ section.disabled
143
+ ? noop
144
+ : () => toggleOpenSection(section.id)
145
+ }
146
+ tabIndex="-1"
147
+ isRequired={section.required}
148
+ />
149
+ </Box>
150
+ )}
151
+ {section.titleIcon && (
152
+ <Cluster align="center">{section.titleIcon}</Cluster>
153
+ )}
154
+ <Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
155
+ <Text
156
+ as="label"
157
+ htmlFor={`radio-input-${idString(section)}`}
158
+ color={CHARADE_GREY}
159
+ >
160
+ {section.title}
161
+ </Text>
162
+ </Box>
163
+ </Cluster>
164
+ {section.rightIcons && (
165
+ <Cluster
166
+ id={`right-icons-${idString(section)}`}
167
+ childGap="0.5rem"
168
+ aria-label={section.rightIconsLabel || null}
169
+ role={section.rightIconsRole || null}
170
+ >
171
+ {section.rightIcons.map(icon => (
172
+ <RightIcon
173
+ src={icon.img}
174
+ key={icon.img}
175
+ fade={!icon.enabled}
176
+ isMobile={isMobile}
177
+ alt={icon.altText}
178
+ aria-disabled={!icon.enabled}
179
+ />
180
+ ))}
181
+ </Cluster>
182
+ )}
183
+ {section.rightTitleContent && (
184
+ <Fragment>{section.rightTitleContent}</Fragment>
185
+ )}
186
+ </Cluster>
187
+ </Box>
188
+ <AnimatePresence initial={false}>
189
+ {openSection === section.id && (
190
+ <Motion
191
+ key={`content-${section.id}`}
192
+ padding="0"
193
+ background={themeValues.bodyBackgroundColor}
194
+ layoutTransition
195
+ initial="closed"
196
+ animate="open"
197
+ exit="closed"
198
+ variants={wrapper}
199
+ extraStyles={`transform-origin: 100% 0; border-top: 0;`}
200
+ >
201
+ {section.content}
202
+ </Motion>
203
+ )}
204
+ </AnimatePresence>
205
+ </Stack>
206
+ </Motion>
207
+ );
208
+ };
209
+
210
+ export default InnerRadioSection;
@@ -1,13 +1,9 @@
1
1
  import React, { createRef, Fragment, useRef, useState } from "react";
2
- import styled from "styled-components";
3
2
  import { themeComponent } from "../../../util/themeUtils";
4
3
  import { fallbackValues } from "./RadioSection.theme";
5
- import { AnimatePresence } from "framer-motion";
6
- import RadioButton from "./radio-button/RadioButton";
7
- import { Box, Cluster, Stack, Motion } from "../../atoms/layouts";
8
- import { createIdFromString, noop, wrapIndex } from "../../../util/general";
9
- import Text from "../../atoms/text";
10
- import { CHARADE_GREY } from "../../../constants/colors";
4
+ import SolidDivider from "../../atoms/solid-divider/SolidDivider";
5
+ import { Box, Stack } from "../../atoms/layouts";
6
+ import { createIdFromString, wrapIndex } from "../../../util/general";
11
7
  import {
12
8
  ARROW_DOWN,
13
9
  ARROW_LEFT,
@@ -16,27 +12,31 @@ import {
16
12
  ENTER,
17
13
  SPACEBAR
18
14
  } from "../../../constants/keyboard";
19
- /*
20
- Takes an array of section objects, each object should look like:
21
- {
22
- title: <React Component(s)>,
23
- id: <String> "identifier of section",
24
- disabled: boolean, (displays section and grayed out radio but disables interaction)
25
- hideRadioButton: boolean, (keeps section displayed but hides radio and disables open/close function),
26
- hidden: boolean, (hides section entirely)
27
- dataQa: string,
28
- content: <React Component(s)> e.g.: <Box><Stack>cool content stuff</Stack></Box> (any collection of components will work),
29
- rightTitleContent: <React Component(s)> (rendered on the very right of the title section, use to supplement "rightIcons" with text, as in expired CC status, or render other custom content)
30
- }
31
-
32
- Also takes an "openSection" which should equal the id of the section that should be open
33
- And a toggleOpenSection. RadioSection will call this function with the id of the section
34
- that it is in. It is up to the user to store the open section value in state up from the component
35
- using a useState() hook, or reducer.
36
-
37
- The section itself comes with some motion to open/close. To add more motion to the content,
38
- wrap your content with a Motion layout primitive and provide appropriate props.
15
+ import InnerRadioSection from "./InnerRadioSection";
16
+ import { MANATEE_GREY } from "../../../constants/colors";
39
17
 
18
+ /**
19
+ - The RadioSection component takes either a flat array (via the 'sections'
20
+ prop) of section objects or a multidimensional array (via the 'groupedSections' prop) of section objects. Note that if using a multidimensional array, the nesting cannot exceed 2 levels deep.
21
+ - Each 'section' object should look like:
22
+ {
23
+ title: <React Component(s)>,
24
+ id: <String> "identifier of section",
25
+ disabled: boolean, (displays section and grayed out radio but disables interaction)
26
+ hideRadioButton: boolean, (keeps section displayed but hides radio and disables open/close function),
27
+ hidden: boolean, (hides section entirely)
28
+ dataQa: string,
29
+ content: <React Component(s)> e.g.: <Box><Stack>cool content stuff</Stack></Box> (any collection of components will work),
30
+ rightTitleContent: <React Component(s)> (rendered on the very right of the title section, use to supplement "rightIcons" with text, as in expired CC status, or render other custom content)
31
+ }
32
+ - It also takes an "openSection" which should equal the id of the section that
33
+ should be open, along with "toggleOpenSection"
34
+ - RadioSection will call "toggleOpenSection" with the id of the section
35
+ that it is in.
36
+ - It is up to the engineer to store the open section value in state up from the
37
+ component using a useState() hook or a reducer.
38
+ - The section itself comes with some motion to open/close. To add more motion
39
+ to the content, wrap your content with a Motion layout primitive and provide appropriate props.
40
40
  */
41
41
 
42
42
  const idString = section =>
@@ -57,9 +57,11 @@ const RadioSection = ({
57
57
  containerStyles = "",
58
58
  ariaDescribedBy,
59
59
  isSectionRequired = false,
60
+ groupedSections,
60
61
  ...rest
61
62
  }) => {
62
63
  const [focused, setFocused] = useState(null);
64
+
63
65
  const sectionRefs = useRef(
64
66
  [...Array(sections.length)].map(() => createRef())
65
67
  );
@@ -93,198 +95,73 @@ const RadioSection = ({
93
95
  }
94
96
  };
95
97
 
96
- const wrapper = {
97
- open: {
98
- height: openHeight,
99
- opacity: 1,
100
- transition: {
101
- duration: 0.3,
102
- ease: [0.04, 0.62, 0.23, 0.98],
103
- staggerChildren: staggeredAnimation ? 0.15 : 0
104
- }
105
- },
106
- closed: {
107
- height: 0,
108
- opacity: 0,
109
- transition: {
110
- duration: 0.3,
111
- ease: [0.04, 0.62, 0.23, 0.98],
112
- staggerChildren: staggeredAnimation ? 0.15 : 0,
113
- staggerDirection: -1
114
- }
115
- }
116
- };
117
-
118
- const borderStyles = `
119
- border-width: 0 0 1px 0;
120
- border-color: ${themeValues.borderColor};
121
- border-style: solid;
122
- border-radius: 0px;
123
- transform-origin: 100% 0;
124
-
125
- &:last-child {
126
- border-width: 0;
127
- }
128
- `;
129
-
130
- const RightIcon = styled.img`
131
- height: ${({ isMobile }) => (isMobile ? "14px" : "18px")};
132
- width: ${({ isMobile }) => (isMobile ? "22px" : "28px")};
133
- ${({ fade }) => fade && "opacity: 0.4;"}
134
- transition: opacity 0.3s ease;
135
- `;
136
-
137
98
  return (
138
99
  <Box
139
100
  padding="1px"
140
101
  border={`1px solid ${themeValues.borderColor}`}
141
102
  borderRadius="4px"
142
103
  extraStyles={containerStyles}
104
+ role="radiogroup"
105
+ aria-required={isSectionRequired}
106
+ {...rest}
143
107
  >
144
- <Stack
145
- childGap="0"
146
- role="radiogroup"
147
- aria-required={isSectionRequired}
148
- {...rest}
149
- >
150
- {sections
151
- .filter(section => !section.hidden)
152
- .map((section, i) => (
153
- <Motion
154
- tabIndex={
155
- section.hideRadioButton || section.disabled ? "-1" : "0"
156
- }
157
- ref={sectionRefs.current[i]}
158
- onBlur={() => !section.disabled && setFocused(null)}
159
- onFocus={() => !section.disabled && setFocused(section.id)}
160
- onKeyDown={e =>
161
- !section.disabled && handleKeyDown(section.id, e, i)
162
- }
163
- hoverStyles={themeValues.focusStyles}
164
- animate={openSection === section.id ? "open" : "closed"}
165
- initial={initiallyOpen ? "open" : "closed"}
166
- key={`item-${section.id}`}
167
- extraStyles={borderStyles}
168
- role="radio"
169
- aria-checked={openSection === section.id}
170
- aria-disabled={section.disabled}
171
- aria-required={section.required}
172
- aria-labelledby={section.id}
173
- aria-describedby={`right-icons-${idString(section)}`}
174
- >
175
- <Stack childGap="0">
176
- <Box
177
- padding={
178
- section.hideRadioButton ? "1.5rem" : "1.25rem 1.5rem"
179
- }
180
- background={
181
- section.disabled
182
- ? themeValues.headingDisabledColor
183
- : themeValues.headingBackgroundColor
184
- }
185
- onClick={
186
- (isMobile && supportsTouch) || section.disabled
187
- ? noop
188
- : () => toggleOpenSection(section.id)
108
+ <Stack childGap="0">
109
+ {!!sections &&
110
+ sections
111
+ .filter(section => !section.hidden)
112
+ .map((section, i) => (
113
+ <Fragment key={`radio-section-${i}`}>
114
+ <InnerRadioSection
115
+ themeValues={themeValues}
116
+ sectionIndex={i}
117
+ section={section}
118
+ sectionRefs={sectionRefs}
119
+ focused={focused}
120
+ setFocused={setFocused}
121
+ openHeight={openHeight}
122
+ openSection={openSection}
123
+ toggleOpenSection={toggleOpenSection}
124
+ onKeyDown={e =>
125
+ !section.disabled && handleKeyDown(section.id, e, i)
189
126
  }
190
- onTouchEnd={
191
- isMobile && supportsTouch && !section.disabled
192
- ? () => toggleOpenSection(section.id)
193
- : noop
194
- }
195
- key={`header-${section.id}`}
196
- borderSize="0px"
197
- borderColor={themeValues.borderColor}
198
- borderWidthOverride={
199
- openSection === section.id && !!section.content
200
- ? `0px 0px 1px 0px`
201
- : ``
202
- }
203
- extraStyles={!section.disabled ? "cursor: pointer;" : ""}
204
- dataQa={section.dataQa ? section.dataQa : section.id}
205
- >
206
- <Cluster
207
- justify="space-between"
208
- align="center"
209
- childGap="1px"
210
- nowrap
211
- >
212
- <Cluster justify="flex-start" align="center" nowrap>
213
- {!section.hideRadioButton && (
214
- <Box padding="0">
215
- <RadioButton
216
- id={`radio-input-${idString(section)}`}
217
- name={idString(section)}
218
- ariaDescribedBy={ariaDescribedBy}
219
- radioOn={openSection === section.id}
220
- radioFocused={focused === section.id}
221
- toggleRadio={
222
- section.disabled
223
- ? noop
224
- : () => toggleOpenSection(section.id)
225
- }
226
- tabIndex="-1"
227
- isRequired={section.required}
228
- />
229
- </Box>
230
- )}
231
- {section.titleIcon && (
232
- <Cluster align="center">{section.titleIcon}</Cluster>
233
- )}
234
- <Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
235
- <Text
236
- as="label"
237
- htmlFor={`radio-input-${idString(section)}`}
238
- color={CHARADE_GREY}
239
- >
240
- {section.title}
241
- </Text>
242
- </Box>
243
- </Cluster>
244
- {section.rightIcons && (
245
- <Cluster
246
- id={`right-icons-${idString(section)}`}
247
- childGap="0.5rem"
248
- aria-label={section.rightIconsLabel || null}
249
- role={section.rightIconsRole || null}
250
- >
251
- {section.rightIcons.map(icon => (
252
- <RightIcon
253
- src={icon.img}
254
- key={icon.img}
255
- fade={!icon.enabled}
256
- isMobile={isMobile}
257
- alt={icon.altText}
258
- aria-disabled={!icon.enabled}
259
- />
260
- ))}
261
- </Cluster>
262
- )}
263
- {section.rightTitleContent && (
264
- <Fragment>{section.rightTitleContent}</Fragment>
127
+ ariaLabelledBy={section.id}
128
+ ariaDescribedBy={`right-icons-${idString(section)}`}
129
+ isLastGroupedItemInSection={false}
130
+ />
131
+ </Fragment>
132
+ ))}
133
+ {!!groupedSections &&
134
+ groupedSections.map((sectionGroup, sectionGroupIndex) =>
135
+ sectionGroup
136
+ .filter(unfilteredSection => !unfilteredSection.hidden)
137
+ .map((section, sectionIndex) => (
138
+ <Fragment key={`key-${sectionGroupIndex}-${sectionIndex}`}>
139
+ <InnerRadioSection
140
+ themeValues={themeValues}
141
+ sectionIndex={`${sectionGroupIndex}-${sectionIndex}`}
142
+ section={section}
143
+ sectionRefs={sectionRefs}
144
+ focused={focused}
145
+ setFocused={setFocused}
146
+ openHeight={openHeight}
147
+ ariaLabelledBy={section.id}
148
+ ariaDescribedBy={`right-icons-${idString(section)}`}
149
+ openSection={openSection}
150
+ toggleOpenSection={toggleOpenSection}
151
+ isLastGroupedItemInSection={
152
+ sectionIndex === sectionGroup.length - 1
153
+ }
154
+ />
155
+ {sectionIndex === sectionGroup.length - 1 &&
156
+ sectionGroupIndex !== groupedSections.length - 1 && (
157
+ <SolidDivider
158
+ borderSize="1px"
159
+ borderColor={MANATEE_GREY}
160
+ />
265
161
  )}
266
- </Cluster>
267
- </Box>
268
- <AnimatePresence initial={false}>
269
- {openSection === section.id && (
270
- <Motion
271
- key={`content-${section.id}`}
272
- padding="0"
273
- background={themeValues.bodyBackgroundColor}
274
- layoutTransition
275
- initial="closed"
276
- animate="open"
277
- exit="closed"
278
- variants={wrapper}
279
- extraStyles={`transform-origin: 100% 0;`}
280
- >
281
- {section.content}
282
- </Motion>
283
- )}
284
- </AnimatePresence>
285
- </Stack>
286
- </Motion>
287
- ))}
162
+ </Fragment>
163
+ ))
164
+ )}
288
165
  </Stack>
289
166
  </Box>
290
167
  );
@@ -1,8 +1,9 @@
1
1
  import React, { useState } from "react";
2
- import { text, boolean } from "@storybook/addon-knobs";
2
+ import { boolean } from "@storybook/addon-knobs";
3
3
 
4
4
  import RadioSection from "./RadioSection";
5
5
  import page from "../../../../.storybook/page";
6
+ import { Box } from "../../atoms/layouts";
6
7
 
7
8
  const story = page({
8
9
  title: "Components|Molecules/RadioSection",
@@ -43,30 +44,106 @@ const cardIconsLabel = `Accepting ${cardIcons
43
44
  ? ` and ${cardIcon.altText}.`
44
45
  : ` ` + cardIcon.altText
45
46
  )}`;
47
+ const groupedSections = [
48
+ [
49
+ {
50
+ id: "new-card-section",
51
+ title: "Group 1: New Card",
52
+ content: <p>The form to add a credit card would go here.</p>,
53
+ rightIconsLabel: cardIconsLabel,
54
+ rightIcons: cardIcons,
55
+ required: true,
56
+ dataQa: "New Card"
57
+ },
58
+ {
59
+ id: "new-bank-section",
60
+ title: "Group 1: New Bank Account",
61
+ content: <p>The form to add a credit card would go here.</p>,
62
+ required: true
63
+ },
64
+
65
+ {
66
+ id: "bar4",
67
+ title: "Group 1: Another One",
68
+ content: <div>Content for another section</div>,
69
+ required: true
70
+ }
71
+ ],
72
+ [
73
+ {
74
+ id: "bar",
75
+ title: "Group 2: Bar",
76
+ content: <div>Content 1</div>,
77
+ required: true
78
+ }
79
+ ],
80
+ [
81
+ {
82
+ id: "bar2",
83
+ title: "Group 3: Bar",
84
+ content: <div>Content 1</div>,
85
+ required: true
86
+ },
87
+ {
88
+ id: "baz",
89
+ title: "Group 3: Baz",
90
+ content: <div>Content 1</div>,
91
+ required: true
92
+ }
93
+ ]
94
+ ];
46
95
  const sections = [
47
96
  {
48
- id: "new-card-section",
49
- title: "New Card",
50
- content: <p>The form to add a credit card would go here.</p>,
97
+ id: "new-card-section-2",
98
+ title: "Section 1: New Card",
99
+ content: <Box>The form to add a credit card would go here.</Box>,
51
100
  rightIconsLabel: cardIconsLabel,
52
101
  rightIcons: cardIcons,
53
102
  required: true
54
103
  },
55
- { id: "bar", title: "Bar", content: <div>Content 1</div>, required: true },
56
- { id: "baz", title: "Baz", content: <div>Content 2</div> }
104
+ {
105
+ id: "bar3",
106
+ title: "Section 1: Bar",
107
+ content: <div>Content 1</div>,
108
+ required: true
109
+ },
110
+ { id: "baz2", title: "Section 1: Baz", content: <div>Content 2</div> }
57
111
  ];
58
112
 
59
113
  export const radioSection = () => {
60
114
  const [openSection, setOpenSection] = useState("");
115
+ const [openGroupedSection, setOpenGroupedSection] = useState("");
61
116
  return (
62
- <RadioSection
63
- isMobile={boolean("isMobile", false, "props")}
64
- supportsTouch={boolean("isMobile", false, "props")}
65
- toggleOpenSection={setOpenSection}
66
- openSection={openSection}
67
- staggeredAnimation={boolean("staggeredAnimation", false, "props")}
68
- sections={sections}
69
- isSectionRequired={true}
70
- />
117
+ <>
118
+ <Box padding="0 1rem" extraStyles="text-align: center;">
119
+ <p>
120
+ Using <b>sections</b>
121
+ </p>
122
+ </Box>
123
+ <RadioSection
124
+ isMobile={boolean("isMobile", false, "props")}
125
+ supportsTouch={boolean("isMobile", false, "props")}
126
+ toggleOpenSection={setOpenSection}
127
+ openSection={openSection}
128
+ staggeredAnimation={boolean("staggeredAnimation", false, "props")}
129
+ sections={sections}
130
+ isSectionRequired={true}
131
+ />
132
+ <Box />
133
+ <Box padding="0 1rem" extraStyles="text-align: center;">
134
+ <p>
135
+ Using <b>groupedSections</b>
136
+ </p>
137
+ </Box>
138
+ <RadioSection
139
+ isMobile={boolean("isMobile", false, "props")}
140
+ supportsTouch={boolean("isMobile", false, "props")}
141
+ toggleOpenSection={setOpenGroupedSection}
142
+ openSection={openGroupedSection}
143
+ staggeredAnimation={boolean("staggeredAnimation", false, "props")}
144
+ groupedSections={groupedSections}
145
+ isSectionRequired={true}
146
+ />
147
+ </>
71
148
  );
72
149
  };