@thecb/components 4.1.14-beta.0 → 4.1.14
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 +390 -171
- package/package.json +1 -1
- package/src/components/atoms/checkbox/Checkbox.js +49 -63
- package/src/components/atoms/dropdown/Dropdown.js +2 -2
- package/src/components/atoms/text/Text.js +0 -2
- package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.js +16 -14
- package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.theme.js +11 -6
- package/src/components/molecules/address-form/AddressForm.js +27 -7
- package/src/components/molecules/email-form/EmailForm.js +27 -7
- package/src/components/molecules/email-form/EmailForm.stories.js +1 -4
- package/src/components/molecules/modal/Modal.js +3 -3
- package/src/components/molecules/obligation/modules/AutopayModalModule.js +38 -47
- package/src/components/molecules/obligation/modules/AutopayModalModule.theme.js +1 -12
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +57 -22
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +26 -7
- package/src/components/molecules/phone-form/PhoneForm.js +27 -7
- package/src/components/molecules/terms-and-conditions/TermsAndConditions.js +40 -12
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +15 -14
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.theme.js +1 -1
- package/src/components/molecules/obligation/modules/AmountModule.stories.js +0 -27
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
2
3
|
import { required, hasLength, matchesRegex } from "redux-freeform";
|
|
3
4
|
import Checkbox from "../../atoms/checkbox";
|
|
4
5
|
import CountryDropdown from "../../atoms/country-dropdown";
|
|
@@ -16,6 +17,10 @@ import {
|
|
|
16
17
|
} from "../../atoms/form-layouts";
|
|
17
18
|
import { Box } from "../../atoms/layouts";
|
|
18
19
|
|
|
20
|
+
const CheckboxWrapper = styled.div`
|
|
21
|
+
outline: none;
|
|
22
|
+
`;
|
|
23
|
+
|
|
19
24
|
const nameOnCardErrors = {
|
|
20
25
|
[required.error]: "Name is required"
|
|
21
26
|
};
|
|
@@ -53,6 +58,12 @@ const PaymentFormCard = ({
|
|
|
53
58
|
saveToWallet,
|
|
54
59
|
walletCheckboxMarked
|
|
55
60
|
}) => {
|
|
61
|
+
const [checkboxFocused, focusCheckbox] = useState(false);
|
|
62
|
+
const handleClick = (e, func) => {
|
|
63
|
+
if (e?.keyCode === 13) {
|
|
64
|
+
func();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
56
67
|
useEffect(() => {
|
|
57
68
|
if (clearOnDismount) {
|
|
58
69
|
return () => actions.form.clear();
|
|
@@ -137,12 +148,20 @@ const PaymentFormCard = ({
|
|
|
137
148
|
</Box>
|
|
138
149
|
)}
|
|
139
150
|
{showWalletCheckbox && (
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
<CheckboxWrapper
|
|
152
|
+
tabIndex="0"
|
|
153
|
+
onFocus={() => focusCheckbox(true)}
|
|
154
|
+
onBlur={() => focusCheckbox(false)}
|
|
155
|
+
onKeyDown={e => handleClick(e, saveToWallet)}
|
|
156
|
+
>
|
|
157
|
+
<Checkbox
|
|
158
|
+
name="credit card checkbox"
|
|
159
|
+
title="Save credit card to wallet"
|
|
160
|
+
checked={walletCheckboxMarked}
|
|
161
|
+
onChange={saveToWallet}
|
|
162
|
+
focused={checkboxFocused}
|
|
163
|
+
/>
|
|
164
|
+
</CheckboxWrapper>
|
|
146
165
|
)}
|
|
147
166
|
</FormInputColumn>
|
|
148
167
|
</FormContainer>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
2
3
|
import { required, hasLength } from "redux-freeform";
|
|
3
4
|
import { createFormat } from "formatted-input";
|
|
4
5
|
import {
|
|
@@ -10,6 +11,10 @@ import Checkbox from "../../atoms/checkbox";
|
|
|
10
11
|
import { noop } from "../../../util/general";
|
|
11
12
|
import { phoneFormats, formatDelimiter } from "../../../util/formats";
|
|
12
13
|
|
|
14
|
+
const CheckboxWrapper = styled.div`
|
|
15
|
+
outline: none;
|
|
16
|
+
`;
|
|
17
|
+
|
|
13
18
|
const PhoneForm = ({
|
|
14
19
|
variant = "default",
|
|
15
20
|
fields,
|
|
@@ -21,6 +26,13 @@ const PhoneForm = ({
|
|
|
21
26
|
saveToWallet,
|
|
22
27
|
walletCheckboxMarked
|
|
23
28
|
}) => {
|
|
29
|
+
const [checkboxFocused, focusCheckbox] = useState(false);
|
|
30
|
+
const handleClick = (e, func) => {
|
|
31
|
+
if (e?.keyCode === 13) {
|
|
32
|
+
func();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
24
36
|
if (clearOnDismount) {
|
|
25
37
|
useEffect(() => () => actions.form.clear(), []);
|
|
26
38
|
}
|
|
@@ -42,12 +54,20 @@ const PhoneForm = ({
|
|
|
42
54
|
onKeyUp={e => e.key === "Enter" && handleSubmit(e)}
|
|
43
55
|
/>
|
|
44
56
|
{showWalletCheckbox && (
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
<CheckboxWrapper
|
|
58
|
+
tabIndex="0"
|
|
59
|
+
onFocus={() => focusCheckbox(true)}
|
|
60
|
+
onBlur={() => focusCheckbox(false)}
|
|
61
|
+
onKeyDown={e => handleClick(e, saveToWallet)}
|
|
62
|
+
>
|
|
63
|
+
<Checkbox
|
|
64
|
+
name="phone checkbox"
|
|
65
|
+
title="Save phone number to wallet"
|
|
66
|
+
checked={walletCheckboxMarked}
|
|
67
|
+
onChange={saveToWallet}
|
|
68
|
+
focused={checkboxFocused}
|
|
69
|
+
/>
|
|
70
|
+
</CheckboxWrapper>
|
|
51
71
|
)}
|
|
52
72
|
</FormInputColumn>
|
|
53
73
|
</FormContainer>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
2
3
|
import Checkbox from "../../atoms/checkbox";
|
|
3
4
|
import Text from "../../atoms/text";
|
|
4
5
|
import { Box, Stack } from "../../atoms/layouts";
|
|
@@ -6,6 +7,12 @@ import DisplayBox from "../../atoms/display-box";
|
|
|
6
7
|
import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
|
|
7
8
|
import TermsAndConditionsModal from "../../molecules/terms-and-conditions-modal";
|
|
8
9
|
|
|
10
|
+
const CheckboxWrapper = styled.div`
|
|
11
|
+
outline: none;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const ModalWrapper = styled.div``;
|
|
15
|
+
|
|
9
16
|
const TermsAndConditions = ({
|
|
10
17
|
onCheck,
|
|
11
18
|
isChecked,
|
|
@@ -14,27 +21,48 @@ const TermsAndConditions = ({
|
|
|
14
21
|
error = false
|
|
15
22
|
}) => {
|
|
16
23
|
const [showTerms, toggleShowTerms] = useState(false);
|
|
24
|
+
const [checkboxFocused, focusCheckbox] = useState(false);
|
|
25
|
+
|
|
26
|
+
const handleClick = (e, func) => {
|
|
27
|
+
if (e?.keyCode === 13) {
|
|
28
|
+
func();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
17
32
|
return (
|
|
18
33
|
<DisplayBox>
|
|
19
34
|
<Stack direction="row">
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
<CheckboxWrapper
|
|
36
|
+
tabIndex="0"
|
|
37
|
+
onFocus={() => focusCheckbox(true)}
|
|
38
|
+
onBlur={() => focusCheckbox(false)}
|
|
39
|
+
onKeyDown={e => handleClick(e, onCheck)}
|
|
40
|
+
>
|
|
41
|
+
<Checkbox
|
|
42
|
+
name="terms"
|
|
43
|
+
error={error}
|
|
44
|
+
checked={isChecked}
|
|
45
|
+
onChange={onCheck}
|
|
46
|
+
focused={checkboxFocused}
|
|
47
|
+
/>
|
|
48
|
+
</CheckboxWrapper>
|
|
26
49
|
<Stack>
|
|
27
50
|
<Text variant="p" fontWeight={FONT_WEIGHT_BOLD}>
|
|
28
51
|
Terms and Conditions
|
|
29
52
|
</Text>
|
|
30
53
|
<Box padding="0">{html}</Box>
|
|
31
54
|
{terms && (
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
<ModalWrapper
|
|
56
|
+
tabIndex="0"
|
|
57
|
+
onKeyDown={e => handleClick(e, () => toggleShowTerms(!showTerms))}
|
|
58
|
+
>
|
|
59
|
+
<TermsAndConditionsModal
|
|
60
|
+
link="Learn More"
|
|
61
|
+
terms={terms}
|
|
62
|
+
isOpen={showTerms}
|
|
63
|
+
toggleOpen={toggleShowTerms}
|
|
64
|
+
/>
|
|
65
|
+
</ModalWrapper>
|
|
38
66
|
)}
|
|
39
67
|
</Stack>
|
|
40
68
|
</Stack>
|
|
@@ -17,6 +17,20 @@ const TermsAndConditionsModal = ({
|
|
|
17
17
|
themeValues
|
|
18
18
|
}) => (
|
|
19
19
|
<Modal
|
|
20
|
+
ModalLink={() => (
|
|
21
|
+
<Text
|
|
22
|
+
variant={variant === "default" ? "pS" : "pXS"}
|
|
23
|
+
onClick={() => toggleOpen(true)}
|
|
24
|
+
color={themeValues.linkColor}
|
|
25
|
+
weight={themeValues.fontWeight}
|
|
26
|
+
hoverStyles={themeValues.modalLinkHoverFocus}
|
|
27
|
+
extraStyles={`cursor: pointer;`}
|
|
28
|
+
tabIndex="0"
|
|
29
|
+
onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
|
|
30
|
+
>
|
|
31
|
+
{link}
|
|
32
|
+
</Text>
|
|
33
|
+
)}
|
|
20
34
|
modalOpen={isOpen}
|
|
21
35
|
hideModal={() => toggleOpen(false)}
|
|
22
36
|
showModal={() => toggleOpen(true)}
|
|
@@ -38,20 +52,7 @@ const TermsAndConditionsModal = ({
|
|
|
38
52
|
toggleAccepted(true);
|
|
39
53
|
toggleOpen(false);
|
|
40
54
|
}}
|
|
41
|
-
|
|
42
|
-
<Text
|
|
43
|
-
variant={variant === "default" ? "pS" : "pXS"}
|
|
44
|
-
onClick={() => toggleOpen(true)}
|
|
45
|
-
onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
|
|
46
|
-
tabIndex="0"
|
|
47
|
-
color={themeValues.linkColor}
|
|
48
|
-
weight={themeValues.fontWeight}
|
|
49
|
-
hoverStyles={themeValues.modalLinkHoverFocus}
|
|
50
|
-
extraStyles={`cursor: pointer;`}
|
|
51
|
-
>
|
|
52
|
-
{link}
|
|
53
|
-
</Text>
|
|
54
|
-
</Modal>
|
|
55
|
+
/>
|
|
55
56
|
);
|
|
56
57
|
|
|
57
58
|
export default themeComponent(
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { text, boolean } from "@storybook/addon-knobs";
|
|
3
|
-
|
|
4
|
-
import AmountModule from "./AmountModule";
|
|
5
|
-
import page from "../../../../../.storybook/page";
|
|
6
|
-
import { noop } from "../../../../util/general";
|
|
7
|
-
|
|
8
|
-
const groupId = "props";
|
|
9
|
-
|
|
10
|
-
export const amountModule = () => (
|
|
11
|
-
<AmountModule
|
|
12
|
-
totalAmountDue={text("totalAmountDue", "123", groupId)}
|
|
13
|
-
autoPayEnabled={boolean("autopayEnabled", true, groupId)}
|
|
14
|
-
isMobile={boolean("isMobile", false, groupId)}
|
|
15
|
-
deactivatePaymentSchedule={noop}
|
|
16
|
-
navigateToSettings={noop}
|
|
17
|
-
autoPaySchedule={{}}
|
|
18
|
-
paymentPlanSchedule={{}}
|
|
19
|
-
isPaymentPlan={boolean("isPaymentPlan", false, groupId)}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const story = page({
|
|
24
|
-
title: "Components|Molecules/AmountModule",
|
|
25
|
-
Component: AmountModule
|
|
26
|
-
});
|
|
27
|
-
export default story;
|