@thecb/components 7.8.3-beta.2 → 7.8.3
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 +151 -184
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +151 -184
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/layouts/Cluster.d.ts +1 -0
- package/src/components/atoms/layouts/Cluster.js +2 -0
- package/src/components/molecules/pagination/Pagination.js +44 -20
- package/src/components/molecules/pagination/index.d.ts +1 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +8 -35
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +10 -37
- package/src/components/molecules/terms-and-conditions/TermsAndConditions.js +1 -3
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +2 -3
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.stories.js +0 -10
- package/src/components/molecules/payment-form-card/index.d.ts +0 -21
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ const Cluster = ({
|
|
|
24
24
|
flexGrow,
|
|
25
25
|
extraStyles,
|
|
26
26
|
children,
|
|
27
|
+
innerWrapperAs = "div",
|
|
27
28
|
...rest
|
|
28
29
|
}) => (
|
|
29
30
|
<ClusterWrapper
|
|
@@ -41,6 +42,7 @@ const Cluster = ({
|
|
|
41
42
|
minHeight={minHeight}
|
|
42
43
|
minWidth={minWidth}
|
|
43
44
|
$nowrap={nowrap}
|
|
45
|
+
as={innerWrapperAs}
|
|
44
46
|
>
|
|
45
47
|
{safeChildren(children, <Fragment />)}
|
|
46
48
|
</ClusterInnerWrapper>
|
|
@@ -23,6 +23,7 @@ const PrevNextPlaceholder = ({ buttonHeight, buttonWidth }) => (
|
|
|
23
23
|
|
|
24
24
|
const PrevNextButton = ({
|
|
25
25
|
action,
|
|
26
|
+
ariaLabel,
|
|
26
27
|
arrowColor,
|
|
27
28
|
borderRadius,
|
|
28
29
|
buttonHeight,
|
|
@@ -34,11 +35,13 @@ const PrevNextButton = ({
|
|
|
34
35
|
padding="0"
|
|
35
36
|
minHeight={buttonHeight}
|
|
36
37
|
extraStyles={`max-height: ${buttonHeight};`}
|
|
38
|
+
as="li"
|
|
37
39
|
>
|
|
38
40
|
<ButtonWithAction
|
|
39
41
|
action={action}
|
|
40
42
|
contentOverride
|
|
41
43
|
dataQa={type}
|
|
44
|
+
aria-label={ariaLabel}
|
|
42
45
|
extraStyles={`
|
|
43
46
|
background-color: ${numberColor};
|
|
44
47
|
border-color: ${numberColor};
|
|
@@ -48,9 +51,6 @@ const PrevNextButton = ({
|
|
|
48
51
|
min-height: 100%;
|
|
49
52
|
min-width: ${buttonWidth};
|
|
50
53
|
padding: 0;
|
|
51
|
-
&:focus {
|
|
52
|
-
outline: none
|
|
53
|
-
}
|
|
54
54
|
`}
|
|
55
55
|
>
|
|
56
56
|
<Box padding="0" extraStyles={type === "prev" && "transform: scaleX(-1)"}>
|
|
@@ -68,19 +68,23 @@ export const getPagesPanel = (page, pagesCount) => {
|
|
|
68
68
|
const space = page === 1 ? PAGING_INIT_SPACE : PAGING_SPACE;
|
|
69
69
|
const pages = [{ index: 1, isButton: true }];
|
|
70
70
|
if (page > space + 1) {
|
|
71
|
-
pages.push({ isDelimiter: true });
|
|
71
|
+
pages.push({ isDelimiter: true, id: "first-delimiter" });
|
|
72
72
|
}
|
|
73
73
|
for (
|
|
74
74
|
let j = Math.max(1, page - space) + 1;
|
|
75
75
|
j < Math.min(lastPageNumber, page + space);
|
|
76
76
|
j++
|
|
77
77
|
) {
|
|
78
|
-
pages.push({ index: j, isButton: true });
|
|
78
|
+
pages.push({ index: j, isButton: true, id: `page-${j}` });
|
|
79
79
|
}
|
|
80
80
|
if (page < lastPageNumber - space) {
|
|
81
|
-
pages.push({ isDelimiter: true });
|
|
81
|
+
pages.push({ isDelimiter: true, id: "last-delimiter" });
|
|
82
82
|
}
|
|
83
|
-
pages.push({
|
|
83
|
+
pages.push({
|
|
84
|
+
index: lastPageNumber,
|
|
85
|
+
isButton: true,
|
|
86
|
+
id: `page-${lastPageNumber}`
|
|
87
|
+
});
|
|
84
88
|
const activePage = pages.find(p => p.index === page);
|
|
85
89
|
if (activePage) {
|
|
86
90
|
activePage.active = true;
|
|
@@ -103,6 +107,7 @@ const Pagination = ({
|
|
|
103
107
|
pageNext,
|
|
104
108
|
pagePrevious,
|
|
105
109
|
setCurrentPage,
|
|
110
|
+
ariaLabel,
|
|
106
111
|
themeValues
|
|
107
112
|
}) => {
|
|
108
113
|
const { isMobile } = useContext(ThemeContext);
|
|
@@ -123,12 +128,9 @@ const Pagination = ({
|
|
|
123
128
|
&:hover {
|
|
124
129
|
background-color: ${themeValues.hoverBackgroundColor}
|
|
125
130
|
}
|
|
126
|
-
&:focus {
|
|
127
|
-
outline: none
|
|
128
|
-
}
|
|
129
131
|
`;
|
|
130
132
|
|
|
131
|
-
const
|
|
133
|
+
const currentPageStyles = `
|
|
132
134
|
border: ${activeBorderWidth} solid ${numberColor ??
|
|
133
135
|
themeValues.numberColor};
|
|
134
136
|
color: ${numberColor ?? themeValues.activeColor};
|
|
@@ -138,14 +140,27 @@ const Pagination = ({
|
|
|
138
140
|
}
|
|
139
141
|
&:hover {
|
|
140
142
|
background-color: initial;
|
|
143
|
+
border: ${activeBorderWidth} solid ${numberColor ??
|
|
144
|
+
themeValues.numberColor};
|
|
145
|
+
background-color: ${themeValues.activeBackgroundColor};
|
|
141
146
|
}
|
|
142
147
|
`;
|
|
143
148
|
|
|
144
149
|
return (
|
|
145
|
-
<Cluster
|
|
150
|
+
<Cluster
|
|
151
|
+
justify="center"
|
|
152
|
+
childGap={childGap}
|
|
153
|
+
overflow={true}
|
|
154
|
+
as="nav"
|
|
155
|
+
role="navigation"
|
|
156
|
+
innerWrapperAs="ul"
|
|
157
|
+
aria-label={ariaLabel}
|
|
158
|
+
extraStyles="> ul { padding: 0px; > li { list-style-type: none; } };"
|
|
159
|
+
>
|
|
146
160
|
{currentPage > 1 ? (
|
|
147
161
|
<PrevNextButton
|
|
148
162
|
action={pagePrevious}
|
|
163
|
+
ariaLabel={`Previous Page`}
|
|
149
164
|
arrowColor={arrowColor ?? themeValues.arrowColor}
|
|
150
165
|
borderRadius={borderRadius}
|
|
151
166
|
buttonHeight={buttonHeight}
|
|
@@ -178,35 +193,43 @@ const Pagination = ({
|
|
|
178
193
|
)
|
|
179
194
|
: getPagesPanel(currentPage, pageCount).map((item, index) =>
|
|
180
195
|
item.isButton ? (
|
|
181
|
-
<Box
|
|
196
|
+
<Box
|
|
197
|
+
padding="0"
|
|
198
|
+
extraStyles={`max-height: ${buttonHeight};`}
|
|
199
|
+
as="li"
|
|
200
|
+
key={item.id}
|
|
201
|
+
>
|
|
182
202
|
<ButtonWithAction
|
|
183
203
|
variant="ghost"
|
|
184
|
-
key={item.index}
|
|
185
204
|
text={item.index}
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
aria-current={item.active ? "page" : undefined}
|
|
206
|
+
aria-label={`${
|
|
207
|
+
item.index == pageCount ? "Last Page, " : ""
|
|
208
|
+
}page ${item.index}`}
|
|
188
209
|
action={
|
|
189
210
|
!item.active
|
|
190
211
|
? () => setCurrentPage({ pageNumber: item.index })
|
|
191
212
|
: noop
|
|
192
213
|
}
|
|
193
214
|
textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
|
|
194
|
-
extraStyles={extraStyles}
|
|
215
|
+
extraStyles={`${extraStyles}${
|
|
216
|
+
item.active ? currentPageStyles : ""
|
|
217
|
+
}`}
|
|
195
218
|
dataQa={index}
|
|
196
219
|
>
|
|
197
220
|
{item.index}
|
|
198
221
|
</ButtonWithAction>
|
|
199
222
|
</Box>
|
|
200
223
|
) : (
|
|
201
|
-
<Box padding="0 10px">
|
|
224
|
+
<Box padding="0 10px" as="li" key={item.id}>
|
|
202
225
|
<Cluster justify="flex-end">
|
|
203
226
|
<Text
|
|
204
|
-
key={index}
|
|
205
227
|
variant="pXL"
|
|
206
228
|
weight={fontWeight}
|
|
207
229
|
color={numberColor ?? themeValues.numberColor}
|
|
230
|
+
role="presentation"
|
|
208
231
|
>
|
|
209
|
-
{"
|
|
232
|
+
{"…"}
|
|
210
233
|
</Text>
|
|
211
234
|
</Cluster>
|
|
212
235
|
</Box>
|
|
@@ -215,6 +238,7 @@ const Pagination = ({
|
|
|
215
238
|
{currentPage < pageCount ? (
|
|
216
239
|
<PrevNextButton
|
|
217
240
|
action={pageNext}
|
|
241
|
+
ariaLabel={`Next Page`}
|
|
218
242
|
arrowColor={arrowColor ?? themeValues.arrowColor}
|
|
219
243
|
borderRadius={borderRadius}
|
|
220
244
|
buttonHeight={buttonHeight}
|
|
@@ -14,9 +14,6 @@ import {
|
|
|
14
14
|
} from "../../atoms/form-layouts";
|
|
15
15
|
import AccountAndRoutingModal from "../account-and-routing-modal";
|
|
16
16
|
import { noop } from "../../../util/general";
|
|
17
|
-
import { Cluster, Cover } from "../../atoms/layouts";
|
|
18
|
-
import TermsAndConditionsModal from "../terms-and-conditions-modal/TermsAndConditionsModal";
|
|
19
|
-
import Text from "../../atoms/text";
|
|
20
17
|
|
|
21
18
|
const PaymentFormACH = ({
|
|
22
19
|
variant = "default",
|
|
@@ -31,18 +28,13 @@ const PaymentFormACH = ({
|
|
|
31
28
|
handleSubmit = noop,
|
|
32
29
|
showWalletCheckbox,
|
|
33
30
|
saveToWallet,
|
|
34
|
-
walletCheckboxMarked
|
|
35
|
-
termsContent,
|
|
36
|
-
termsTitle = "Terms & Conditions"
|
|
31
|
+
walletCheckboxMarked
|
|
37
32
|
}) => {
|
|
38
33
|
if (clearOnDismount) {
|
|
39
34
|
useEffect(() => () => actions.form.clear(), []);
|
|
40
35
|
}
|
|
41
36
|
const [showRouting, toggleShowRouting] = useState(false);
|
|
42
37
|
const [showAccount, toggleShowAccount] = useState(false);
|
|
43
|
-
const [termsModalOpen, setTermsModalOpen] = useState(false);
|
|
44
|
-
const showTerms = !!termsContent;
|
|
45
|
-
const showTermsLinkVariant = showWalletCheckbox ? "p" : "pS";
|
|
46
38
|
|
|
47
39
|
const nameErrors = {
|
|
48
40
|
[required.error]: "Name is required"
|
|
@@ -161,32 +153,13 @@ const PaymentFormACH = ({
|
|
|
161
153
|
hidden={hideDefaultPayment}
|
|
162
154
|
/>
|
|
163
155
|
)}
|
|
164
|
-
{
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
onChange={saveToWallet}
|
|
172
|
-
/>
|
|
173
|
-
)}
|
|
174
|
-
{showTerms && (
|
|
175
|
-
<Cover singleChild>
|
|
176
|
-
<Cluster childGap={0}>
|
|
177
|
-
<Text variant={showTermsLinkVariant}>View </Text>
|
|
178
|
-
<TermsAndConditionsModal
|
|
179
|
-
link={termsTitle}
|
|
180
|
-
linkVariant={showTermsLinkVariant}
|
|
181
|
-
terms={termsContent}
|
|
182
|
-
title={termsTitle}
|
|
183
|
-
isOpen={termsModalOpen}
|
|
184
|
-
toggleOpen={setTermsModalOpen}
|
|
185
|
-
/>
|
|
186
|
-
</Cluster>
|
|
187
|
-
</Cover>
|
|
188
|
-
)}
|
|
189
|
-
</Cluster>
|
|
156
|
+
{showWalletCheckbox && (
|
|
157
|
+
<Checkbox
|
|
158
|
+
name="bank checkbox"
|
|
159
|
+
title="Save checking account to wallet"
|
|
160
|
+
checked={walletCheckboxMarked}
|
|
161
|
+
onChange={saveToWallet}
|
|
162
|
+
/>
|
|
190
163
|
)}
|
|
191
164
|
</FormInputColumn>
|
|
192
165
|
</FormContainer>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useContext
|
|
1
|
+
import React, { useEffect, useContext } from "react";
|
|
2
2
|
import { ThemeContext } from "styled-components";
|
|
3
3
|
import {
|
|
4
4
|
required,
|
|
@@ -26,10 +26,8 @@ import {
|
|
|
26
26
|
FormContainer,
|
|
27
27
|
FormInputRow
|
|
28
28
|
} from "../../atoms/form-layouts";
|
|
29
|
-
import { Box
|
|
29
|
+
import { Box } from "../../atoms/layouts";
|
|
30
30
|
import withWindowSize from "../../withWindowSize";
|
|
31
|
-
import TermsAndConditionsModal from "../terms-and-conditions-modal/TermsAndConditionsModal";
|
|
32
|
-
import Text from "../../atoms/text";
|
|
33
31
|
|
|
34
32
|
const PaymentFormCard = ({
|
|
35
33
|
variant = "default",
|
|
@@ -42,15 +40,9 @@ const PaymentFormCard = ({
|
|
|
42
40
|
showWalletCheckbox,
|
|
43
41
|
saveToWallet,
|
|
44
42
|
walletCheckboxMarked,
|
|
45
|
-
deniedCards
|
|
46
|
-
termsContent,
|
|
47
|
-
termsTitle = "Terms & Conditions"
|
|
43
|
+
deniedCards
|
|
48
44
|
}) => {
|
|
49
45
|
const { isMobile } = useContext(ThemeContext);
|
|
50
|
-
const [termsModalOpen, setTermsModalOpen] = useState(false);
|
|
51
|
-
const showTerms = !!termsContent;
|
|
52
|
-
const showTermsLinkVariant = showWalletCheckbox ? "p" : "pS";
|
|
53
|
-
|
|
54
46
|
useEffect(() => {
|
|
55
47
|
if (deniedCards) {
|
|
56
48
|
deniedCards.map(card =>
|
|
@@ -185,32 +177,13 @@ const PaymentFormCard = ({
|
|
|
185
177
|
/>
|
|
186
178
|
</Box>
|
|
187
179
|
)}
|
|
188
|
-
{
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
onChange={saveToWallet}
|
|
196
|
-
/>
|
|
197
|
-
)}
|
|
198
|
-
{showTerms && (
|
|
199
|
-
<Cover singleChild>
|
|
200
|
-
<Cluster childGap={0}>
|
|
201
|
-
<Text variant={showTermsLinkVariant}>View </Text>
|
|
202
|
-
<TermsAndConditionsModal
|
|
203
|
-
link={termsTitle}
|
|
204
|
-
linkVariant={showTermsLinkVariant}
|
|
205
|
-
terms={termsContent}
|
|
206
|
-
title={termsTitle}
|
|
207
|
-
isOpen={termsModalOpen}
|
|
208
|
-
toggleOpen={setTermsModalOpen}
|
|
209
|
-
/>
|
|
210
|
-
</Cluster>
|
|
211
|
-
</Cover>
|
|
212
|
-
)}
|
|
213
|
-
</Cluster>
|
|
180
|
+
{showWalletCheckbox && (
|
|
181
|
+
<Checkbox
|
|
182
|
+
name="credit card checkbox"
|
|
183
|
+
title="Save credit card to wallet"
|
|
184
|
+
checked={walletCheckboxMarked}
|
|
185
|
+
onChange={saveToWallet}
|
|
186
|
+
/>
|
|
214
187
|
)}
|
|
215
188
|
</FormInputColumn>
|
|
216
189
|
</FormContainer>
|
|
@@ -9,8 +9,7 @@ const TermsAndConditions = ({
|
|
|
9
9
|
isChecked,
|
|
10
10
|
html,
|
|
11
11
|
terms,
|
|
12
|
-
error = false
|
|
13
|
-
linkVariant
|
|
12
|
+
error = false
|
|
14
13
|
}) => {
|
|
15
14
|
const [showTerms, toggleShowTerms] = useState(false);
|
|
16
15
|
return (
|
|
@@ -32,7 +31,6 @@ const TermsAndConditions = ({
|
|
|
32
31
|
terms={terms}
|
|
33
32
|
isOpen={showTerms}
|
|
34
33
|
toggleOpen={toggleShowTerms}
|
|
35
|
-
linkVariant={linkVariant}
|
|
36
34
|
/>
|
|
37
35
|
)}
|
|
38
36
|
</Stack>
|
|
@@ -14,7 +14,6 @@ const TermsAndConditionsModal = ({
|
|
|
14
14
|
acceptText,
|
|
15
15
|
terms,
|
|
16
16
|
variant,
|
|
17
|
-
linkVariant = "p",
|
|
18
17
|
themeValues
|
|
19
18
|
}) => (
|
|
20
19
|
<Modal
|
|
@@ -43,14 +42,14 @@ const TermsAndConditionsModal = ({
|
|
|
43
42
|
}}
|
|
44
43
|
>
|
|
45
44
|
<Text
|
|
46
|
-
variant={
|
|
45
|
+
variant={variant === "default" ? "pS" : "pXS"}
|
|
47
46
|
onClick={() => toggleOpen(true)}
|
|
48
47
|
onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
|
|
49
48
|
tabIndex="0"
|
|
50
49
|
color={themeValues.linkColor}
|
|
51
50
|
weight={themeValues.fontWeight}
|
|
52
51
|
hoverStyles={themeValues.modalLinkHoverFocus}
|
|
53
|
-
extraStyles={`display: inline-block; width: fit-content
|
|
52
|
+
extraStyles={`display: inline-block; width: fit-content;`}
|
|
54
53
|
>
|
|
55
54
|
{link}
|
|
56
55
|
</Text>
|
package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.stories.js
CHANGED
|
@@ -11,15 +11,6 @@ const variants = {
|
|
|
11
11
|
};
|
|
12
12
|
const groupId = "props";
|
|
13
13
|
|
|
14
|
-
const linkVariants = {
|
|
15
|
-
p: "p",
|
|
16
|
-
pL: "pL",
|
|
17
|
-
pS: "pS",
|
|
18
|
-
pXS: "pXS",
|
|
19
|
-
pXXS: "pXXs",
|
|
20
|
-
pXL: "PXL"
|
|
21
|
-
};
|
|
22
|
-
|
|
23
14
|
export const termsAndConditionsModal = () => (
|
|
24
15
|
<TermsAndConditionsModal
|
|
25
16
|
link={text("text", "Show modal", groupId)}
|
|
@@ -30,7 +21,6 @@ export const termsAndConditionsModal = () => (
|
|
|
30
21
|
acceptText={text("acceptText", "Accept", groupId)}
|
|
31
22
|
terms={text("terms", "terms and conditions", groupId)}
|
|
32
23
|
variant={select("variants", variants, "default", groupId)}
|
|
33
|
-
linkVariant={select("linkVariants", linkVariants, groupId)}
|
|
34
24
|
/>
|
|
35
25
|
);
|
|
36
26
|
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Expand from "../../../util/expand";
|
|
3
|
-
|
|
4
|
-
export interface PaymentFormCardProps {
|
|
5
|
-
variant?: string;
|
|
6
|
-
hideZipCode?: boolean;
|
|
7
|
-
clearOnDismount?: boolean;
|
|
8
|
-
fields,
|
|
9
|
-
actions,
|
|
10
|
-
showErrors,
|
|
11
|
-
handleSubmit = noop,
|
|
12
|
-
showWalletCheckbox,
|
|
13
|
-
saveToWallet,
|
|
14
|
-
walletCheckboxMarked,
|
|
15
|
-
deniedCards,
|
|
16
|
-
termsContent,
|
|
17
|
-
termsTitle = "Terms & Conditions"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Paragraph: React.FC<Expand<PaymentFormCardProps> &
|
|
21
|
-
React.HTMLAttributes<HTMLElement>>;
|