@thecb/components 4.1.13 → 4.1.14-beta.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.
Files changed (25) hide show
  1. package/dist/index.cjs.js +374 -514
  2. package/package.json +1 -1
  3. package/src/components/atoms/checkbox/Checkbox.js +63 -49
  4. package/src/components/atoms/dropdown/Dropdown.js +2 -2
  5. package/src/components/atoms/form-layouts/FormLayouts.theme.js +2 -2
  6. package/src/components/atoms/form-select/FormSelect.js +50 -15
  7. package/src/components/atoms/form-select/FormSelect.stories.js +4 -2
  8. package/src/components/atoms/form-select/FormSelect.styled.js +6 -6
  9. package/src/components/atoms/form-select/FormSelect.theme.js +52 -0
  10. package/src/components/atoms/text/Text.js +2 -0
  11. package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.js +14 -16
  12. package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.theme.js +6 -11
  13. package/src/components/molecules/address-form/AddressForm.js +7 -27
  14. package/src/components/molecules/email-form/EmailForm.js +7 -27
  15. package/src/components/molecules/email-form/EmailForm.stories.js +4 -1
  16. package/src/components/molecules/modal/Modal.js +3 -3
  17. package/src/components/molecules/obligation/modules/AmountModule.stories.js +27 -0
  18. package/src/components/molecules/obligation/modules/AutopayModalModule.js +47 -38
  19. package/src/components/molecules/obligation/modules/AutopayModalModule.theme.js +12 -1
  20. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +22 -57
  21. package/src/components/molecules/payment-form-card/PaymentFormCard.js +7 -26
  22. package/src/components/molecules/phone-form/PhoneForm.js +7 -27
  23. package/src/components/molecules/terms-and-conditions/TermsAndConditions.js +12 -40
  24. package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +14 -15
  25. package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.theme.js +1 -1
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import Modal from "../../modal";
3
3
  import ButtonWithAction from "../../../atoms/button-with-action";
4
+ import Text from "../../../atoms/text";
4
5
  import { AutopayOnIcon } from "../../../atoms/icons";
5
6
  import { Box, Cluster } from "../../../atoms/layouts";
6
7
  import { fallbackValues } from "./AutopayModalModule.theme";
@@ -61,48 +62,56 @@ const AutopayModal = ({
61
62
  `;
62
63
  return (
63
64
  <Modal
64
- ModalLink={() =>
65
- buttonLinkType ? (
66
- <ButtonWithAction
67
- text={autoPayActive ? `Manage ${planType}` : `Set Up ${planType}`}
68
- variant="tertiary"
69
- action={() => {
70
- toggleModal(true);
71
- }}
72
- dataQa="Manage Autopay"
73
- extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
74
- />
75
- ) : (
76
- <Box
77
- padding="0"
78
- onClick={() => {
79
- toggleModal(true);
80
- }}
81
- hoverStyles={hoverStyles}
82
- activeStyles={activeStyles}
83
- extraStyles={defaultStyles}
84
- >
85
- <Cluster
86
- justify={isMobile ? "flex-start" : "flex-end"}
87
- align="center"
88
- >
89
- <AutopayOnIcon />
90
- <ButtonWithAction
91
- text={`${planType} On`}
92
- variant="smallGhost"
93
- dataQa="Autopay On"
94
- textExtraStyles={`font-size: 0.875rem; `}
95
- extraStyles={`min-width: auto; padding: 0 0 0 6px;`}
96
- />
97
- </Cluster>
98
- </Box>
99
- )
100
- }
101
65
  showModal={() => toggleModal(true)}
102
66
  hideModal={() => toggleModal(false)}
103
67
  modalOpen={modalOpen}
104
68
  {...modalExtraProps}
105
- />
69
+ >
70
+ {buttonLinkType ? (
71
+ <ButtonWithAction
72
+ text={autoPayActive ? `Manage ${planType}` : `Set Up ${planType}`}
73
+ variant="tertiary"
74
+ action={() => {
75
+ toggleModal(true);
76
+ }}
77
+ dataQa="Manage Autopay"
78
+ extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
79
+ />
80
+ ) : (
81
+ <Box
82
+ padding="0"
83
+ onClick={() => {
84
+ toggleModal(true);
85
+ }}
86
+ hoverStyles={hoverStyles}
87
+ activeStyles={activeStyles}
88
+ extraStyles={defaultStyles}
89
+ >
90
+ <Cluster
91
+ justify={isMobile ? "flex-start" : "flex-end"}
92
+ align="center"
93
+ >
94
+ <AutopayOnIcon />
95
+ <Text
96
+ variant="pS"
97
+ onClick={() => toggleModal(true)}
98
+ onKeyPress={e => {
99
+ console.log({ e });
100
+ e.key === "Enter" && toggleModal(true);
101
+ }}
102
+ tabIndex="0"
103
+ dataQa={`${planType} On`}
104
+ color={themeValues.linkColor}
105
+ weight={themeValues.fontWeight}
106
+ hoverStyles={themeValues.modalLinkHoverFocus}
107
+ extraStyles={`padding: 0 0 0 6px;`}
108
+ >
109
+ {`${planType} On`}
110
+ </Text>
111
+ </Cluster>
112
+ </Box>
113
+ )}
114
+ </Modal>
106
115
  );
107
116
  };
108
117
 
@@ -1,9 +1,20 @@
1
+ import { FONT_WEIGHT_REGULAR } from "../../../../constants/style_constants";
2
+
1
3
  const color = "#15749D";
2
4
  const hoverColor = "#116285";
3
5
  const activeColor = "#0E506D";
6
+ const linkColor = "#357fb8";
7
+ const fontWeight = FONT_WEIGHT_REGULAR;
8
+ const modalLinkHoverFocus = `outline: none;
9
+ cursor: pointer;
10
+ text-decoration: underline;
11
+ text-decoration-color: #357fb8;`;
4
12
 
5
13
  export const fallbackValues = {
6
14
  color,
7
15
  hoverColor,
8
- activeColor
16
+ activeColor,
17
+ linkColor,
18
+ fontWeight,
19
+ modalLinkHoverFocus
9
20
  };
@@ -1,5 +1,4 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import styled from "styled-components";
3
2
  import Checkbox from "../../atoms/checkbox";
4
3
  import {
5
4
  required,
@@ -16,12 +15,6 @@ import {
16
15
  import AccountAndRoutingModal from "../account-and-routing-modal";
17
16
  import { noop } from "../../../util/general";
18
17
 
19
- const ModalWrapper = styled.div``;
20
-
21
- const CheckboxWrapper = styled.div`
22
- outline: none;
23
- `;
24
-
25
18
  const PaymentFormACH = ({
26
19
  variant = "default",
27
20
  defaultMethod,
@@ -37,12 +30,6 @@ const PaymentFormACH = ({
37
30
  saveToWallet,
38
31
  walletCheckboxMarked
39
32
  }) => {
40
- const [checkboxFocused, focusCheckbox] = useState(false);
41
- const handleClick = (e, func) => {
42
- if (e?.keyCode === 13) {
43
- func();
44
- }
45
- };
46
33
  if (clearOnDismount) {
47
34
  useEffect(() => () => actions.form.clear(), []);
48
35
  }
@@ -91,22 +78,15 @@ const PaymentFormACH = ({
91
78
  fieldActions={actions.fields.routingNumber}
92
79
  showErrors={showErrors}
93
80
  helperModal={() => (
94
- <ModalWrapper
95
- tabIndex="0"
96
- onKeyDown={e =>
97
- e.key === "Enter" && toggleShowAccount(!showRouting)
98
- }
99
- >
100
- <AccountAndRoutingModal
101
- link="What is this?"
102
- title="Where is my routing number?"
103
- content="Your routing number is the 9-digit number in the bottom left
81
+ <AccountAndRoutingModal
82
+ link="What is this?"
83
+ title="Where is my routing number?"
84
+ content="Your routing number is the 9-digit number in the bottom left
104
85
  corner of your check."
105
- imageType="Routing"
106
- isOpen={showRouting}
107
- toggleOpen={toggleShowRouting}
108
- />
109
- </ModalWrapper>
86
+ imageType="Routing"
87
+ isOpen={showRouting}
88
+ toggleOpen={toggleShowRouting}
89
+ />
110
90
  )}
111
91
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
112
92
  />
@@ -125,22 +105,15 @@ const PaymentFormACH = ({
125
105
  fieldActions={actions.fields.accountNumber}
126
106
  showErrors={showErrors}
127
107
  helperModal={() => (
128
- <ModalWrapper
129
- tabIndex="0"
130
- onKeyDown={e =>
131
- e.key === "Enter" && toggleShowAccount(!showAccount)
132
- }
133
- >
134
- <AccountAndRoutingModal
135
- link="What is this?"
136
- title="Where is my account number?"
137
- content="Your account number is usually the 10-digit number in the bottom
108
+ <AccountAndRoutingModal
109
+ link="What is this?"
110
+ title="Where is my account number?"
111
+ content="Your account number is usually the 10-digit number in the bottom
138
112
  of your check to the right of the routing number."
139
- imageType="Account"
140
- isOpen={showAccount}
141
- toggleOpen={toggleShowAccount}
142
- />
143
- </ModalWrapper>
113
+ imageType="Account"
114
+ isOpen={showAccount}
115
+ toggleOpen={toggleShowAccount}
116
+ />
144
117
  )}
145
118
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
146
119
  />
@@ -176,20 +149,12 @@ const PaymentFormACH = ({
176
149
  />
177
150
  )}
178
151
  {showWalletCheckbox && (
179
- <CheckboxWrapper
180
- tabIndex="0"
181
- onFocus={() => focusCheckbox(true)}
182
- onBlur={() => focusCheckbox(false)}
183
- onKeyDown={e => handleClick(e, saveToWallet)}
184
- >
185
- <Checkbox
186
- name="bank checkbox"
187
- title="Save bank account to wallet"
188
- checked={walletCheckboxMarked}
189
- onChange={saveToWallet}
190
- focused={checkboxFocused}
191
- />
192
- </CheckboxWrapper>
152
+ <Checkbox
153
+ name="bank checkbox"
154
+ title="Save bank account to wallet"
155
+ checked={walletCheckboxMarked}
156
+ onChange={saveToWallet}
157
+ />
193
158
  )}
194
159
  </FormInputColumn>
195
160
  </FormContainer>
@@ -1,5 +1,4 @@
1
- import React, { useEffect, useState } from "react";
2
- import styled from "styled-components";
1
+ import React, { useEffect } from "react";
3
2
  import { required, hasLength, matchesRegex } from "redux-freeform";
4
3
  import Checkbox from "../../atoms/checkbox";
5
4
  import CountryDropdown from "../../atoms/country-dropdown";
@@ -17,10 +16,6 @@ import {
17
16
  } from "../../atoms/form-layouts";
18
17
  import { Box } from "../../atoms/layouts";
19
18
 
20
- const CheckboxWrapper = styled.div`
21
- outline: none;
22
- `;
23
-
24
19
  const nameOnCardErrors = {
25
20
  [required.error]: "Name is required"
26
21
  };
@@ -58,12 +53,6 @@ const PaymentFormCard = ({
58
53
  saveToWallet,
59
54
  walletCheckboxMarked
60
55
  }) => {
61
- const [checkboxFocused, focusCheckbox] = useState(false);
62
- const handleClick = (e, func) => {
63
- if (e?.keyCode === 13) {
64
- func();
65
- }
66
- };
67
56
  useEffect(() => {
68
57
  if (clearOnDismount) {
69
58
  return () => actions.form.clear();
@@ -148,20 +137,12 @@ const PaymentFormCard = ({
148
137
  </Box>
149
138
  )}
150
139
  {showWalletCheckbox && (
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>
140
+ <Checkbox
141
+ name="credit card checkbox"
142
+ title="Save credit card to wallet"
143
+ checked={walletCheckboxMarked}
144
+ onChange={saveToWallet}
145
+ />
165
146
  )}
166
147
  </FormInputColumn>
167
148
  </FormContainer>
@@ -1,5 +1,4 @@
1
- import React, { useEffect, useState } from "react";
2
- import styled from "styled-components";
1
+ import React, { useEffect } from "react";
3
2
  import { required, hasLength } from "redux-freeform";
4
3
  import { createFormat } from "formatted-input";
5
4
  import {
@@ -11,10 +10,6 @@ import Checkbox from "../../atoms/checkbox";
11
10
  import { noop } from "../../../util/general";
12
11
  import { phoneFormats, formatDelimiter } from "../../../util/formats";
13
12
 
14
- const CheckboxWrapper = styled.div`
15
- outline: none;
16
- `;
17
-
18
13
  const PhoneForm = ({
19
14
  variant = "default",
20
15
  fields,
@@ -26,13 +21,6 @@ const PhoneForm = ({
26
21
  saveToWallet,
27
22
  walletCheckboxMarked
28
23
  }) => {
29
- const [checkboxFocused, focusCheckbox] = useState(false);
30
- const handleClick = (e, func) => {
31
- if (e?.keyCode === 13) {
32
- func();
33
- }
34
- };
35
-
36
24
  if (clearOnDismount) {
37
25
  useEffect(() => () => actions.form.clear(), []);
38
26
  }
@@ -54,20 +42,12 @@ const PhoneForm = ({
54
42
  onKeyUp={e => e.key === "Enter" && handleSubmit(e)}
55
43
  />
56
44
  {showWalletCheckbox && (
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>
45
+ <Checkbox
46
+ name="phone checkbox"
47
+ title="Save phone number to wallet"
48
+ checked={walletCheckboxMarked}
49
+ onChange={saveToWallet}
50
+ />
71
51
  )}
72
52
  </FormInputColumn>
73
53
  </FormContainer>
@@ -1,5 +1,4 @@
1
1
  import React, { useState } from "react";
2
- import styled from "styled-components";
3
2
  import Checkbox from "../../atoms/checkbox";
4
3
  import Text from "../../atoms/text";
5
4
  import { Box, Stack } from "../../atoms/layouts";
@@ -7,12 +6,6 @@ import DisplayBox from "../../atoms/display-box";
7
6
  import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
8
7
  import TermsAndConditionsModal from "../../molecules/terms-and-conditions-modal";
9
8
 
10
- const CheckboxWrapper = styled.div`
11
- outline: none;
12
- `;
13
-
14
- const ModalWrapper = styled.div``;
15
-
16
9
  const TermsAndConditions = ({
17
10
  onCheck,
18
11
  isChecked,
@@ -21,48 +14,27 @@ const TermsAndConditions = ({
21
14
  error = false
22
15
  }) => {
23
16
  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
-
32
17
  return (
33
18
  <DisplayBox>
34
19
  <Stack direction="row">
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>
20
+ <Checkbox
21
+ name="terms"
22
+ error={error}
23
+ checked={isChecked}
24
+ onChange={onCheck}
25
+ />
49
26
  <Stack>
50
27
  <Text variant="p" fontWeight={FONT_WEIGHT_BOLD}>
51
28
  Terms and Conditions
52
29
  </Text>
53
30
  <Box padding="0">{html}</Box>
54
31
  {terms && (
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>
32
+ <TermsAndConditionsModal
33
+ link="Learn More"
34
+ terms={terms}
35
+ isOpen={showTerms}
36
+ toggleOpen={toggleShowTerms}
37
+ />
66
38
  )}
67
39
  </Stack>
68
40
  </Stack>
@@ -17,20 +17,6 @@ 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
- )}
34
20
  modalOpen={isOpen}
35
21
  hideModal={() => toggleOpen(false)}
36
22
  showModal={() => toggleOpen(true)}
@@ -52,7 +38,20 @@ const TermsAndConditionsModal = ({
52
38
  toggleAccepted(true);
53
39
  toggleOpen(false);
54
40
  }}
55
- />
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>
56
55
  );
57
56
 
58
57
  export default themeComponent(
@@ -13,7 +13,7 @@ const fontWeight = {
13
13
  footer: FONT_WEIGHT_SEMIBOLD
14
14
  };
15
15
  const modalLinkHoverFocus = {
16
- default: ``,
16
+ default: `outline: none; text-decoration: underline;`,
17
17
  footer: `outline: none; text-decoration: underline;`
18
18
  };
19
19