@thecb/components 11.1.16 → 11.2.0
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 +57 -21
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +57 -21
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/obligation/modules/InactiveTitleModule.js +1 -1
- package/src/components/molecules/radio-section/RadioSection.js +85 -43
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +9 -5
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ const InactiveTitleModule = ({ title, subtitle, autoPayEnabled }) => (
|
|
|
28
28
|
Unable to load account details
|
|
29
29
|
</Detail>
|
|
30
30
|
<Detail variant="extraSmall" as="p" color={BLACK}>
|
|
31
|
-
{`This may mean
|
|
31
|
+
{`This may mean the balance has been paid and was removed from the system, or that there was an error loading it. .${
|
|
32
32
|
autoPayEnabled
|
|
33
33
|
? " You may disable autopay for this account by pressing the 'Turn off Autopay' button."
|
|
34
34
|
: ""
|
|
@@ -57,7 +57,7 @@ const RadioSection = ({
|
|
|
57
57
|
containerStyles = "",
|
|
58
58
|
ariaDescribedBy,
|
|
59
59
|
isSectionRequired = false,
|
|
60
|
-
groupedSections,
|
|
60
|
+
groupedSections = [],
|
|
61
61
|
borderOverride,
|
|
62
62
|
...rest
|
|
63
63
|
}) => {
|
|
@@ -67,32 +67,59 @@ const RadioSection = ({
|
|
|
67
67
|
[...Array(sections.length)].map(() => createRef())
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// Flatten the groupedSections while keeping track of indices
|
|
71
|
+
const flattenedGroupedSections = groupedSections.flatMap(
|
|
72
|
+
(group, groupIndex) =>
|
|
73
|
+
group.map((section, sectionIndex) => ({
|
|
74
|
+
...section,
|
|
75
|
+
groupIndex,
|
|
76
|
+
sectionIndex
|
|
77
|
+
}))
|
|
78
|
+
);
|
|
79
|
+
const groupedSectionsRefs = useRef(
|
|
80
|
+
[...Array(flattenedGroupedSections.length)].map(() => createRef())
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const getFlatGroupIndex = (groupIndex, sectionIndex) =>
|
|
84
|
+
flattenedGroupedSections.findIndex(
|
|
85
|
+
item =>
|
|
86
|
+
item.groupIndex === groupIndex && item.sectionIndex === sectionIndex
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const handleKeyDown = (e, sectionID, sectionIndex, isGroup) => {
|
|
90
|
+
const { currentTarget, target, keyCode } = e;
|
|
91
|
+
if (currentTarget !== target) {
|
|
72
92
|
return;
|
|
73
93
|
}
|
|
94
|
+
const refs = isGroup ? groupedSectionsRefs : sectionRefs;
|
|
95
|
+
const currSection = isGroup ? flattenedGroupedSections : sections;
|
|
74
96
|
|
|
75
97
|
// Allow Enter and Space to select a section
|
|
76
|
-
if (
|
|
98
|
+
if (keyCode === ENTER || keyCode === SPACEBAR) {
|
|
77
99
|
e.preventDefault();
|
|
78
|
-
toggleOpenSection(
|
|
100
|
+
toggleOpenSection(sectionID);
|
|
79
101
|
}
|
|
80
102
|
|
|
81
103
|
// Allow Up and Down arrow navigation between sections
|
|
82
104
|
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
105
|
+
keyCode == ARROW_UP ||
|
|
106
|
+
keyCode == ARROW_DOWN ||
|
|
107
|
+
keyCode == ARROW_LEFT ||
|
|
108
|
+
keyCode == ARROW_RIGHT
|
|
87
109
|
) {
|
|
88
110
|
e.preventDefault();
|
|
89
111
|
const indexIncrement =
|
|
90
|
-
|
|
91
|
-
const nextIndex = wrapIndex(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
112
|
+
keyCode == ARROW_RIGHT || keyCode == ARROW_DOWN ? 1 : -1;
|
|
113
|
+
const nextIndex = wrapIndex(
|
|
114
|
+
sectionIndex + indexIncrement,
|
|
115
|
+
currSection.length
|
|
116
|
+
);
|
|
117
|
+
const nextRef = refs?.current[nextIndex]?.current;
|
|
118
|
+
if (nextRef) {
|
|
119
|
+
nextRef.focus();
|
|
120
|
+
const nextRadioID = currSection[nextIndex]?.id;
|
|
121
|
+
setFocused(nextRadioID);
|
|
122
|
+
}
|
|
96
123
|
}
|
|
97
124
|
};
|
|
98
125
|
|
|
@@ -123,7 +150,7 @@ const RadioSection = ({
|
|
|
123
150
|
openSection={openSection}
|
|
124
151
|
toggleOpenSection={toggleOpenSection}
|
|
125
152
|
onKeyDown={e =>
|
|
126
|
-
!section.disabled && handleKeyDown(section.id,
|
|
153
|
+
!section.disabled && handleKeyDown(e, section.id, i)
|
|
127
154
|
}
|
|
128
155
|
ariaLabelledBy={section.id}
|
|
129
156
|
ariaDescribedBy={`right-icons-${idString(section)}`}
|
|
@@ -135,33 +162,48 @@ const RadioSection = ({
|
|
|
135
162
|
groupedSections.map((sectionGroup, sectionGroupIndex) =>
|
|
136
163
|
sectionGroup
|
|
137
164
|
.filter(unfilteredSection => !unfilteredSection.hidden)
|
|
138
|
-
.map((section, sectionIndex) =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
.map((section, sectionIndex) => {
|
|
166
|
+
const flatGroupSectionIndex = getFlatGroupIndex(
|
|
167
|
+
sectionGroupIndex,
|
|
168
|
+
sectionIndex
|
|
169
|
+
);
|
|
170
|
+
return (
|
|
171
|
+
<Fragment key={`key-${sectionGroupIndex}-${sectionIndex}`}>
|
|
172
|
+
<InnerRadioSection
|
|
173
|
+
themeValues={themeValues}
|
|
174
|
+
sectionIndex={flatGroupSectionIndex}
|
|
175
|
+
section={section}
|
|
176
|
+
sectionRefs={groupedSectionsRefs}
|
|
177
|
+
focused={focused}
|
|
178
|
+
setFocused={setFocused}
|
|
179
|
+
openHeight={openHeight}
|
|
180
|
+
ariaLabelledBy={section.id}
|
|
181
|
+
ariaDescribedBy={`right-icons-${idString(section)}`}
|
|
182
|
+
openSection={openSection}
|
|
183
|
+
toggleOpenSection={toggleOpenSection}
|
|
184
|
+
onKeyDown={e =>
|
|
185
|
+
!section.disabled &&
|
|
186
|
+
handleKeyDown(
|
|
187
|
+
e,
|
|
188
|
+
section.id,
|
|
189
|
+
flatGroupSectionIndex,
|
|
190
|
+
true
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
isLastGroupedItemInSection={
|
|
194
|
+
sectionIndex === sectionGroup.length - 1
|
|
195
|
+
}
|
|
196
|
+
/>
|
|
197
|
+
{sectionIndex === sectionGroup.length - 1 &&
|
|
198
|
+
sectionGroupIndex !== groupedSections.length - 1 && (
|
|
199
|
+
<SolidDivider
|
|
200
|
+
borderSize="1px"
|
|
201
|
+
borderColor={MANATEE_GREY}
|
|
202
|
+
/>
|
|
203
|
+
)}
|
|
204
|
+
</Fragment>
|
|
205
|
+
);
|
|
206
|
+
})
|
|
165
207
|
)}
|
|
166
208
|
</Stack>
|
|
167
209
|
</Box>
|
|
@@ -25,21 +25,25 @@ const RadioButton = ({
|
|
|
25
25
|
const buttonBorder = {
|
|
26
26
|
onFocused: {
|
|
27
27
|
borderColor: themeValues.activeColor,
|
|
28
|
-
|
|
28
|
+
outlineWidth: "3px",
|
|
29
|
+
outlineColor: themeValues.activeColor,
|
|
29
30
|
outlineOffset: "2px"
|
|
30
31
|
},
|
|
31
32
|
offFocused: {
|
|
32
33
|
borderColor: themeValues.activeColor,
|
|
33
|
-
|
|
34
|
+
outlineWidth: "3px",
|
|
35
|
+
outlineColor: themeValues.activeColor,
|
|
34
36
|
outlineOffset: "2px"
|
|
35
37
|
},
|
|
36
38
|
on: {
|
|
37
39
|
borderColor: themeValues.activeColor,
|
|
38
|
-
|
|
40
|
+
outlineWidth: "0px",
|
|
41
|
+
outlineColor: "rgba(0, 0, 0, 0)"
|
|
39
42
|
},
|
|
40
43
|
off: {
|
|
41
44
|
borderColor: themeValues.inactiveColor,
|
|
42
|
-
|
|
45
|
+
outlineWidth: "0px",
|
|
46
|
+
outlineColor: "rgba(0, 0, 0, 0)"
|
|
43
47
|
}
|
|
44
48
|
};
|
|
45
49
|
|
|
@@ -106,7 +110,7 @@ const RadioButton = ({
|
|
|
106
110
|
width="24px"
|
|
107
111
|
variants={buttonBorder}
|
|
108
112
|
display="flex"
|
|
109
|
-
extraStyles={`justify-content: center; align-items: center;`}
|
|
113
|
+
extraStyles={`outline: 0px solid rgba(0, 0, 0, 0); justify-content: center; align-items: center;`}
|
|
110
114
|
>
|
|
111
115
|
<Motion variants={buttonCenter} borderRadius="8px" />
|
|
112
116
|
</Motion>
|