@thecb/components 4.1.2 → 4.1.6-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 (28) hide show
  1. package/dist/index.cjs.js +648 -75
  2. package/package.json +2 -2
  3. package/src/components/atoms/checkbox/Checkbox.js +2 -2
  4. package/src/components/atoms/checkbox/Checkbox.theme.js +3 -3
  5. package/src/components/atoms/dropdown/Dropdown.js +9 -3
  6. package/src/components/atoms/form-select/FormSelect.js +3 -1
  7. package/src/components/atoms/icons/AchReturnIcon.js +33 -0
  8. package/src/components/atoms/icons/AllocatedIcon.js +33 -0
  9. package/src/components/atoms/icons/CalendarIcon.js +33 -0
  10. package/src/components/atoms/icons/ChargebackIcon.js +33 -0
  11. package/src/components/atoms/icons/ChargebackReversalIcon.js +33 -0
  12. package/src/components/atoms/icons/DuplicateIcon.js +33 -0
  13. package/src/components/atoms/icons/ErroredIcon.js +33 -0
  14. package/src/components/atoms/icons/FailedIcon.js +33 -0
  15. package/src/components/atoms/icons/PendingIcon.js +33 -0
  16. package/src/components/atoms/icons/RefundIcon.js +34 -0
  17. package/src/components/atoms/icons/RejectedIcon.js +33 -0
  18. package/src/components/atoms/icons/RejectedVelocityIcon.js +33 -0
  19. package/src/components/atoms/icons/SuccessfulIcon.js +33 -0
  20. package/src/components/atoms/icons/VoidedIcon.js +33 -0
  21. package/src/components/atoms/icons/icons.stories.js +29 -1
  22. package/src/components/atoms/icons/index.js +29 -1
  23. package/src/components/molecules/address-form/AddressForm.js +34 -2
  24. package/src/components/molecules/email-form/EmailForm.js +34 -2
  25. package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +6 -4
  26. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +30 -1
  27. package/src/components/molecules/payment-form-card/PaymentFormCard.js +33 -2
  28. package/src/components/molecules/phone-form/PhoneForm.js +35 -3
@@ -24,6 +24,20 @@ import AutopayOnIcon from "./AutopayOnIcon";
24
24
  import NotFoundIcon from "./NotFoundIcon";
25
25
  import SearchIcon from "./SearchIcon";
26
26
  import WalletIcon from "./WalletIcon";
27
+ import AchReturnIcon from "./AchReturnIcon";
28
+ import AllocatedIcon from "./AllocatedIcon";
29
+ import CalendarIcon from "./CalendarIcon";
30
+ import ChargebackIcon from "./ChargebackIcon";
31
+ import ChargebackReversalIcon from "./ChargebackReversalIcon";
32
+ import DuplicateIcon from "./DuplicateIcon";
33
+ import ErroredIcon from "./ErroredIcon";
34
+ import FailedIcon from "./FailedIcon";
35
+ import PendingIcon from "./PendingIcon";
36
+ import RefundIcon from "./RefundIcon";
37
+ import RejectedIcon from "./RejectedIcon";
38
+ import RejectedVelocityIcon from "./RejectedVelocityIcon";
39
+ import SuccessfulIcon from "./SuccessfulIcon";
40
+ import VoidedIcon from "./VoidedIcon";
27
41
 
28
42
  export {
29
43
  AccountsIcon,
@@ -51,5 +65,19 @@ export {
51
65
  AutopayOnIcon,
52
66
  NotFoundIcon,
53
67
  SearchIcon,
54
- WalletIcon
68
+ WalletIcon,
69
+ AchReturnIcon,
70
+ AllocatedIcon,
71
+ CalendarIcon,
72
+ ChargebackIcon,
73
+ ChargebackReversalIcon,
74
+ DuplicateIcon,
75
+ ErroredIcon,
76
+ FailedIcon,
77
+ PendingIcon,
78
+ RefundIcon,
79
+ RejectedIcon,
80
+ RejectedVelocityIcon,
81
+ SuccessfulIcon,
82
+ VoidedIcon
55
83
  };
@@ -1,6 +1,8 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { required, hasLength } from "redux-freeform";
3
+ import styled from "styled-components";
3
4
  import StateProvinceDropdown from "../../atoms/state-province-dropdown";
5
+ import Checkbox from "../../atoms/checkbox";
4
6
  // import CountryDropdown from "../../atoms/country-dropdown";
5
7
  import { zipFormat } from "../../../util/formats";
6
8
  import { noop } from "../../../util/general";
@@ -10,14 +12,28 @@ import {
10
12
  FormInputColumn
11
13
  } from "../../atoms/form-layouts";
12
14
 
15
+ const CheckboxWrapper = styled.div`
16
+ outline: none;
17
+ `;
18
+
13
19
  const AddressForm = ({
14
20
  variant = "default",
15
21
  fields,
16
22
  actions,
17
23
  clearOnDismount,
18
24
  showErrors,
19
- handleSubmit = noop
25
+ handleSubmit = noop,
26
+ showWalletCheckbox,
27
+ saveToWallet,
28
+ walletCheckboxMarked
20
29
  }) => {
30
+ const [checkboxFocused, focusCheckbox] = useState(false);
31
+
32
+ const handleClick = (e, func) => {
33
+ if (e?.keyCode === 13) {
34
+ func();
35
+ }
36
+ };
21
37
  if (clearOnDismount) {
22
38
  useEffect(() => () => actions.form.clear(), []);
23
39
  }
@@ -103,6 +119,22 @@ const AddressForm = ({
103
119
  showErrors={showErrors}
104
120
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
105
121
  />
122
+ {showWalletCheckbox && (
123
+ <CheckboxWrapper
124
+ tabIndex="0"
125
+ onFocus={() => focusCheckbox(true)}
126
+ onBlur={() => focusCheckbox(false)}
127
+ onKeyDown={e => handleClick(e, saveToWallet)}
128
+ >
129
+ <Checkbox
130
+ name="address checkbox"
131
+ title="Save address to wallet"
132
+ checked={walletCheckboxMarked}
133
+ onChange={saveToWallet}
134
+ focused={checkboxFocused}
135
+ />
136
+ </CheckboxWrapper>
137
+ )}
106
138
  </FormInputColumn>
107
139
  </FormContainer>
108
140
  );
@@ -1,13 +1,19 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useState } from "react";
2
+ import styled from "styled-components";
2
3
  import { required, isProbablyEmail } from "redux-freeform";
3
4
  import {
4
5
  FormInput,
5
6
  FormContainer,
6
7
  FormInputColumn
7
8
  } from "../../atoms/form-layouts";
9
+ import Checkbox from "../../atoms/checkbox";
8
10
  import Paragraph from "../../atoms/paragraph";
9
11
  import { noop } from "../../../util/general";
10
12
 
13
+ const CheckboxWrapper = styled.div`
14
+ outline: none;
15
+ `;
16
+
11
17
  const EmailForm = ({
12
18
  variant = "default",
13
19
  clearOnDismount,
@@ -15,8 +21,18 @@ const EmailForm = ({
15
21
  actions,
16
22
  showErrors,
17
23
  guestCheckout,
18
- handleSubmit = noop
24
+ handleSubmit = noop,
25
+ showWalletCheckbox,
26
+ saveToWallet,
27
+ walletCheckboxMarked
19
28
  }) => {
29
+ const [checkboxFocused, focusCheckbox] = useState(false);
30
+ const handleClick = (e, func) => {
31
+ if (e?.keyCode === 13) {
32
+ func();
33
+ }
34
+ };
35
+
20
36
  if (clearOnDismount) {
21
37
  useEffect(() => () => actions.form.clear(), []);
22
38
  }
@@ -42,6 +58,22 @@ const EmailForm = ({
42
58
  showErrors={showErrors}
43
59
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
44
60
  />
61
+ {showWalletCheckbox && (
62
+ <CheckboxWrapper
63
+ tabIndex="0"
64
+ onFocus={() => focusCheckbox(true)}
65
+ onBlur={() => focusCheckbox(false)}
66
+ onKeyDown={e => handleClick(e, saveToWallet)}
67
+ >
68
+ <Checkbox
69
+ name="email checkbox"
70
+ title="Save email address to wallet"
71
+ checked={walletCheckboxMarked}
72
+ onChange={saveToWallet}
73
+ focused={checkboxFocused}
74
+ />
75
+ </CheckboxWrapper>
76
+ )}
45
77
  </FormInputColumn>
46
78
  </FormContainer>
47
79
  );
@@ -10,6 +10,8 @@ const PaymentButtonBar = ({
10
10
  forwardButtonText = "Next",
11
11
  forwardButtonAction,
12
12
  forwardButtonLoading,
13
+ forwardButtonVariant = "primary",
14
+ backButtonVariant = "secondary",
13
15
  backButtonAction,
14
16
  cancelURL,
15
17
  cancelText = "Cancel",
@@ -23,7 +25,7 @@ const PaymentButtonBar = ({
23
25
  <ButtonWithLink
24
26
  text={cancelText}
25
27
  url={cancelURL}
26
- variant="secondary"
28
+ variant={backButtonVariant}
27
29
  extraStyles={isMobile && "flex-grow: 1"}
28
30
  dataQa={cancelText}
29
31
  />
@@ -31,7 +33,7 @@ const PaymentButtonBar = ({
31
33
  backButtonAction && (
32
34
  <ButtonWithAction
33
35
  text="Back"
34
- variant="secondary"
36
+ variant={backButtonVariant}
35
37
  action={backButtonAction}
36
38
  extraStyles={isMobile && "flex-grow: 1"}
37
39
  dataQa="Back"
@@ -43,7 +45,7 @@ const PaymentButtonBar = ({
43
45
  <ButtonWithLink
44
46
  url={redirectURL}
45
47
  text={redirectText}
46
- variant="primary"
48
+ variant={forwardButtonVariant}
47
49
  extraStyles={isMobile && "flex-grow: 1"}
48
50
  dataQa={redirectText}
49
51
  />
@@ -51,7 +53,7 @@ const PaymentButtonBar = ({
51
53
  forwardButtonAction && (
52
54
  <ButtonWithAction
53
55
  text={forwardButtonText}
54
- variant="primary"
56
+ variant={forwardButtonVariant}
55
57
  action={forwardButtonAction}
56
58
  isLoading={forwardButtonLoading}
57
59
  extraStyles={isMobile && "flex-grow: 1"}
@@ -18,6 +18,10 @@ import { noop } from "../../../util/general";
18
18
 
19
19
  const ModalWrapper = styled.div``;
20
20
 
21
+ const CheckboxWrapper = styled.div`
22
+ outline: none;
23
+ `;
24
+
21
25
  const PaymentFormACH = ({
22
26
  variant = "default",
23
27
  defaultMethod,
@@ -28,8 +32,17 @@ const PaymentFormACH = ({
28
32
  fields,
29
33
  actions,
30
34
  showErrors,
31
- handleSubmit = noop
35
+ handleSubmit = noop,
36
+ showWalletCheckbox,
37
+ saveToWallet,
38
+ walletCheckboxMarked
32
39
  }) => {
40
+ const [checkboxFocused, focusCheckbox] = useState(false);
41
+ const handleClick = (e, func) => {
42
+ if (e?.keyCode === 13) {
43
+ func();
44
+ }
45
+ };
33
46
  if (clearOnDismount) {
34
47
  useEffect(() => () => actions.form.clear(), []);
35
48
  }
@@ -162,6 +175,22 @@ const PaymentFormACH = ({
162
175
  hidden={hideDefaultPayment}
163
176
  />
164
177
  )}
178
+ {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>
193
+ )}
165
194
  </FormInputColumn>
166
195
  </FormContainer>
167
196
  );
@@ -1,5 +1,7 @@
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";
4
+ import Checkbox from "../../atoms/checkbox";
3
5
  import { checkCardBrand, noop } from "../../../util/general";
4
6
  import { expirationDateFormat, creditCardFormat } from "../../../util/formats";
5
7
  import {
@@ -10,6 +12,10 @@ import {
10
12
  } from "../../atoms/form-layouts";
11
13
  import { Box } from "../../atoms/layouts";
12
14
 
15
+ const CheckboxWrapper = styled.div`
16
+ outline: none;
17
+ `;
18
+
13
19
  const nameOnCardErrors = {
14
20
  [required.error]: "Name is required"
15
21
  };
@@ -39,8 +45,17 @@ const PaymentFormCard = ({
39
45
  actions,
40
46
  showErrors,
41
47
  handleSubmit = noop,
42
- isMobile
48
+ isMobile,
49
+ showWalletCheckbox,
50
+ saveToWallet,
51
+ walletCheckboxMarked
43
52
  }) => {
53
+ const [checkboxFocused, focusCheckbox] = useState(false);
54
+ const handleClick = (e, func) => {
55
+ if (e?.keyCode === 13) {
56
+ func();
57
+ }
58
+ };
44
59
  useEffect(() => {
45
60
  if (clearOnDismount) {
46
61
  return () => actions.form.clear();
@@ -105,6 +120,22 @@ const PaymentFormCard = ({
105
120
  />
106
121
  </Box>
107
122
  )}
123
+ {showWalletCheckbox && (
124
+ <CheckboxWrapper
125
+ tabIndex="0"
126
+ onFocus={() => focusCheckbox(true)}
127
+ onBlur={() => focusCheckbox(false)}
128
+ onKeyDown={e => handleClick(e, saveToWallet)}
129
+ >
130
+ <Checkbox
131
+ name="credit card checkbox"
132
+ title="Save credit card to wallet"
133
+ checked={walletCheckboxMarked}
134
+ onChange={saveToWallet}
135
+ focused={checkboxFocused}
136
+ />
137
+ </CheckboxWrapper>
138
+ )}
108
139
  </FormInputColumn>
109
140
  </FormContainer>
110
141
  );
@@ -1,5 +1,5 @@
1
- import React, { useEffect } from "react";
2
- import { phoneFormats, formatDelimiter } from "../../../util/formats";
1
+ import React, { useEffect, useState } from "react";
2
+ import styled from "styled-components";
3
3
  import { required, hasLength } from "redux-freeform";
4
4
  import { createFormat } from "formatted-input";
5
5
  import {
@@ -7,7 +7,13 @@ import {
7
7
  FormContainer,
8
8
  FormInputColumn
9
9
  } from "../../atoms/form-layouts";
10
+ import Checkbox from "../../atoms/checkbox";
10
11
  import { noop } from "../../../util/general";
12
+ import { phoneFormats, formatDelimiter } from "../../../util/formats";
13
+
14
+ const CheckboxWrapper = styled.div`
15
+ outline: none;
16
+ `;
11
17
 
12
18
  const PhoneForm = ({
13
19
  variant = "default",
@@ -15,8 +21,18 @@ const PhoneForm = ({
15
21
  actions,
16
22
  clearOnDismount,
17
23
  showErrors,
18
- handleSubmit = noop
24
+ handleSubmit = noop,
25
+ showWalletCheckbox,
26
+ saveToWallet,
27
+ walletCheckboxMarked
19
28
  }) => {
29
+ const [checkboxFocused, focusCheckbox] = useState(false);
30
+ const handleClick = (e, func) => {
31
+ if (e?.keyCode === 13) {
32
+ func();
33
+ }
34
+ };
35
+
20
36
  if (clearOnDismount) {
21
37
  useEffect(() => () => actions.form.clear(), []);
22
38
  }
@@ -37,6 +53,22 @@ const PhoneForm = ({
37
53
  formatter={createFormat(phoneFormats, formatDelimiter)}
38
54
  onKeyUp={e => e.key === "Enter" && handleSubmit(e)}
39
55
  />
56
+ {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>
71
+ )}
40
72
  </FormInputColumn>
41
73
  </FormContainer>
42
74
  );