@thecb/components 9.1.4-beta.6 → 9.1.4

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 +204 -203
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +204 -203
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -3
  7. package/src/components/atoms/dropdown/Dropdown.js +2 -3
  8. package/src/components/atoms/form-layouts/FormInput.js +0 -3
  9. package/src/components/atoms/form-select/FormSelect.js +1 -3
  10. package/src/components/atoms/layouts/Motion.styled.js +1 -1
  11. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -3
  12. package/src/components/molecules/address-form/AddressForm.js +1 -10
  13. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +3 -22
  14. package/src/components/molecules/payment-form-ach/PaymentFormACH.state.js +2 -2
  15. package/src/components/molecules/payment-form-card/PaymentFormCard.js +1 -18
  16. package/src/components/molecules/radio-section/RadioSection.js +1 -4
  17. package/src/components/molecules/radio-section/RadioSection.stories.js +3 -4
  18. package/src/components/molecules/radio-section/radio-button/RadioButton.js +8 -8
  19. package/src/components/molecules/radio-section/radio-button/RadioButton.theme.js +2 -2
  20. package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
  21. package/src/.DS_Store +0 -0
  22. package/src/components/.DS_Store +0 -0
  23. package/src/components/atoms/.DS_Store +0 -0
  24. package/src/components/atoms/icons/.DS_Store +0 -0
  25. package/src/util/formUtils.js +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.1.4-beta.6",
3
+ "version": "9.1.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -10,8 +10,7 @@ const CountryDropdown = ({
10
10
  fieldActions,
11
11
  showErrors,
12
12
  onChange,
13
- dataQa = null,
14
- isRequired = false
13
+ dataQa = null
15
14
  }) => (
16
15
  <FormSelect
17
16
  options={options}
@@ -23,7 +22,6 @@ const CountryDropdown = ({
23
22
  showErrors={showErrors}
24
23
  onChange={onChange}
25
24
  autocompleteValue="country-name"
26
- isRequired={isRequired}
27
25
  />
28
26
  );
29
27
  export default CountryDropdown;
@@ -105,8 +105,7 @@ const Dropdown = ({
105
105
  ariaDescribedby,
106
106
  autocompleteValue, // browser autofill value, like country-name
107
107
  smoothScroll = true,
108
- ariaInvalid = false,
109
- isRequired = false
108
+ ariaInvalid = false
110
109
  }) => {
111
110
  const [inputValue, setInputValue] = useState("");
112
111
  const [optionsState, setOptionsState] = useState([]);
@@ -329,7 +328,7 @@ const Dropdown = ({
329
328
  }}
330
329
  padding="12px"
331
330
  placeholder={getSelection()}
332
- required={options.required || isRequired}
331
+ required={options.required}
333
332
  role="combobox"
334
333
  themeValues={themeValues}
335
334
  title={hasTitles ? getSelection() : null}
@@ -116,7 +116,6 @@ const FormInput = ({
116
116
  extraStyles,
117
117
  removeFromValue, // regex of characters to remove before setting value
118
118
  dataQa = null,
119
- isRequired = false,
120
119
  ...props
121
120
  }) => {
122
121
  const [showPassword, setShowPassword] = useState(false);
@@ -222,7 +221,6 @@ const FormInput = ({
222
221
  $extraStyles={extraStyles}
223
222
  data-qa={dataQa || labelTextWhenNoError}
224
223
  autoComplete={autocompleteValue}
225
- required={isRequired}
226
224
  {...props}
227
225
  />
228
226
  ) : (
@@ -249,7 +247,6 @@ const FormInput = ({
249
247
  $extraStyles={extraStyles}
250
248
  data-qa={dataQa || labelTextWhenNoError}
251
249
  autoComplete={autocompleteValue}
252
- required={isRequired}
253
250
  {...props}
254
251
  />
255
252
  )}
@@ -24,8 +24,7 @@ const FormSelect = ({
24
24
  autocompleteValue, // browser autofill value, like country-name
25
25
  smoothScroll = true, // whether the browser should animate scroll to selected item on first open
26
26
  dataQa = null,
27
- widthFitOptions = false,
28
- isRequired = false
27
+ widthFitOptions = false
29
28
  }) => {
30
29
  const [open, setOpen] = useState(false);
31
30
  const dropdownRef = useRef(null);
@@ -95,7 +94,6 @@ const FormSelect = ({
95
94
  disabled={disabled}
96
95
  autocompleteValue={autocompleteValue}
97
96
  smoothScroll={smoothScroll}
98
- required={isRequired}
99
97
  />
100
98
  <Stack direction="row" justify="space-between">
101
99
  <Text
@@ -8,7 +8,7 @@ export const MotionWrapper = styled(motion.div)`
8
8
  padding: ${({ padding }) => padding};
9
9
  border: ${({ borderShorthand }) => borderShorthand};
10
10
  border-color: ${({ borderColor }) => borderColor};
11
- border-width: ${({ borderSize }) => borderSize};
11
+ border-size: ${({ borderSize }) => borderSize};
12
12
  border-style: ${({ borderStyle }) => borderStyle};
13
13
  border-width: ${({ borderWidth }) => borderWidth};
14
14
  border-radius: ${({ borderRadius }) => borderRadius};
@@ -9,8 +9,7 @@ const FormStateDropdown = ({
9
9
  field,
10
10
  fieldActions,
11
11
  showErrors,
12
- countryCode,
13
- isRequired = false
12
+ countryCode
14
13
  }) => {
15
14
  const placeholder =
16
15
  countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
@@ -24,7 +23,6 @@ const FormStateDropdown = ({
24
23
  errorMessages={errorMessages}
25
24
  showErrors={showErrors}
26
25
  autocompleteValue="address-level1"
27
- isRequired={isRequired}
28
26
  />
29
27
  );
30
28
  };
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect } from "react";
1
+ import React, { useEffect } from "react";
2
2
  import { required, hasLength } from "redux-freeform";
3
3
  import StateProvinceDropdown from "../../atoms/state-province-dropdown";
4
4
  import Checkbox from "../../atoms/checkbox";
@@ -10,7 +10,6 @@ import {
10
10
  FormContainer,
11
11
  FormInputColumn
12
12
  } from "../../atoms/form-layouts";
13
- import { getIsRequiredFromValidators } from "../../../util/formUtils";
14
13
 
15
14
  const AddressForm = ({
16
15
  variant = "default",
@@ -72,7 +71,6 @@ const AddressForm = ({
72
71
  }}
73
72
  showErrors={showErrors}
74
73
  dataQa="Country"
75
- isRequired={getIsRequiredFromValidators(useCallback)(fields.city)}
76
74
  />
77
75
  <FormInput
78
76
  labelTextWhenNoError="Address"
@@ -83,7 +81,6 @@ const AddressForm = ({
83
81
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
84
82
  autocompleteValue="address-line1"
85
83
  dataQa="Address"
86
- isRequired={getIsRequiredFromValidators(useCallback)(fields.street1)}
87
84
  />
88
85
  <FormInput
89
86
  labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
@@ -93,7 +90,6 @@ const AddressForm = ({
93
90
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
94
91
  autocompleteValue="address-line2"
95
92
  dataQa="Address Line 2"
96
- isRequired={getIsRequiredFromValidators(useCallback)(fields.street2)}
97
93
  />
98
94
  <FormInput
99
95
  labelTextWhenNoError="City"
@@ -104,7 +100,6 @@ const AddressForm = ({
104
100
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
105
101
  autocompleteValue="address-level2"
106
102
  dataQa="City"
107
- isRequired={getIsRequiredFromValidators(useCallback)(fields.city)}
108
103
  />
109
104
  <StateProvinceDropdown
110
105
  labelTextWhenNoError={isUS ? "State" : "State or Province"}
@@ -115,9 +110,6 @@ const AddressForm = ({
115
110
  showErrors={showErrors}
116
111
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
117
112
  dataQa="State or Province"
118
- isRequired={getIsRequiredFromValidators(useCallback)(
119
- fields.stateProvince
120
- )}
121
113
  />
122
114
  <FormInput
123
115
  isNum={isUS}
@@ -130,7 +122,6 @@ const AddressForm = ({
130
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
131
123
  autocompleteValue="postal-code"
132
124
  dataQa="Zip code"
133
- isRequired={getIsRequiredFromValidators(useCallback)(fields.zip)}
134
125
  />
135
126
  {showWalletCheckbox && (
136
127
  <Checkbox
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState, useCallback } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import Checkbox from "../../atoms/checkbox";
3
3
  import {
4
4
  required,
@@ -16,7 +16,6 @@ import AccountAndRoutingModal from "../account-and-routing-modal";
16
16
  import { noop } from "../../../util/general";
17
17
  import { Cluster, Cover } from "../../atoms/layouts";
18
18
  import TermsAndConditions from "../terms-and-conditions";
19
- import { getIsRequiredFromValidators } from "../../../util/formUtils";
20
19
 
21
20
  const PaymentFormACH = ({
22
21
  variant = "default",
@@ -51,8 +50,7 @@ const PaymentFormACH = ({
51
50
  };
52
51
  const confirmRoutingNumberErrors = {
53
52
  [matchesField.error]:
54
- "Confirm routing number field must match routing number",
55
- [required.error]: "Confirm routing number is required"
53
+ "Confirm routing number field must match routing number"
56
54
  };
57
55
  const accountNumberErrors = {
58
56
  [required.error]: "Account number is required",
@@ -60,8 +58,7 @@ const PaymentFormACH = ({
60
58
  };
61
59
  const confirmAccountNumberErrors = {
62
60
  [matchesField.error]:
63
- "Confirm account number field must match account number",
64
- [required.error]: "Confirm account number is required"
61
+ "Confirm account number field must match account number"
65
62
  };
66
63
  const accountTypeErrors = {
67
64
  [required.error]: "Account type is required"
@@ -79,7 +76,6 @@ const PaymentFormACH = ({
79
76
  showErrors={showErrors}
80
77
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
81
78
  autocompleteValue="name"
82
- isRequired={getIsRequiredFromValidators(useCallback)(fields.name)}
83
79
  />
84
80
  <FormInput
85
81
  labelTextWhenNoError="Routing number"
@@ -88,9 +84,6 @@ const PaymentFormACH = ({
88
84
  field={fields.routingNumber}
89
85
  fieldActions={actions.fields.routingNumber}
90
86
  showErrors={showErrors}
91
- isRequired={getIsRequiredFromValidators(useCallback)(
92
- fields.routingNumber
93
- )}
94
87
  isNum
95
88
  helperModal={() => (
96
89
  <AccountAndRoutingModal
@@ -113,9 +106,6 @@ const PaymentFormACH = ({
113
106
  fieldActions={actions.fields.confirmRoutingNumber}
114
107
  showErrors={showErrors}
115
108
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
116
- isRequired={getIsRequiredFromValidators(useCallback)(
117
- fields.confirmRoutingNumber
118
- )}
119
109
  isNum
120
110
  />
121
111
  <FormInput
@@ -125,9 +115,6 @@ const PaymentFormACH = ({
125
115
  field={fields.accountNumber}
126
116
  fieldActions={actions.fields.accountNumber}
127
117
  showErrors={showErrors}
128
- isRequired={getIsRequiredFromValidators(useCallback)(
129
- fields.accountNumber
130
- )}
131
118
  isNum
132
119
  helperModal={() => (
133
120
  <AccountAndRoutingModal
@@ -150,9 +137,6 @@ const PaymentFormACH = ({
150
137
  fieldActions={actions.fields.confirmAccountNumber}
151
138
  showErrors={showErrors}
152
139
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
153
- isRequired={getIsRequiredFromValidators(useCallback)(
154
- fields.confirmAccountNumber
155
- )}
156
140
  isNum
157
141
  />
158
142
  {allowBankAccountType && (
@@ -168,9 +152,6 @@ const PaymentFormACH = ({
168
152
  showErrors={showErrors}
169
153
  errorMessages={accountTypeErrors}
170
154
  field={fields.accountType}
171
- isRequired={getIsRequiredFromValidators(useCallback)(
172
- fields.accountType
173
- )}
174
155
  />
175
156
  )}
176
157
  {!hideDefaultPayment && (
@@ -16,7 +16,7 @@ const formConfig = {
16
16
  constraints: [onlyIntegers(), hasLength(0, 9)]
17
17
  },
18
18
  confirmRoutingNumber: {
19
- validators: [matchesField("routingNumber"), required()],
19
+ validators: [matchesField("routingNumber")],
20
20
  constraints: [onlyIntegers(), hasLength(0, 9)]
21
21
  },
22
22
  accountNumber: {
@@ -24,7 +24,7 @@ const formConfig = {
24
24
  constraints: [onlyIntegers(), hasLength(0, 17)]
25
25
  },
26
26
  confirmAccountNumber: {
27
- validators: [matchesField("accountNumber"), required()],
27
+ validators: [matchesField("accountNumber")],
28
28
  constraints: [onlyIntegers(), hasLength(0, 17)]
29
29
  },
30
30
  accountType: {
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useContext, useCallback } from "react";
1
+ import React, { useEffect, useContext, useState } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import {
4
4
  required,
@@ -29,7 +29,6 @@ import {
29
29
  import { Box, Cluster, Cover } from "../../atoms/layouts";
30
30
  import withWindowSize from "../../withWindowSize";
31
31
  import TermsAndConditions from "../terms-and-conditions";
32
- import { getIsRequiredFromValidators } from "../../../util/formUtils";
33
32
 
34
33
  const PaymentFormCard = ({
35
34
  variant = "default",
@@ -111,9 +110,6 @@ const PaymentFormCard = ({
111
110
  }}
112
111
  showErrors={showErrors}
113
112
  dataQa="Country"
114
- isRequired={getIsRequiredFromValidators(useCallback)(
115
- fields.country
116
- )}
117
113
  />
118
114
  )}
119
115
  <FormInput
@@ -125,9 +121,6 @@ const PaymentFormCard = ({
125
121
  showErrors={showErrors}
126
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
127
123
  autocompleteValue="cc-name"
128
- isRequired={getIsRequiredFromValidators(useCallback)(
129
- fields.nameOnCard
130
- )}
131
124
  />
132
125
  <FormInput
133
126
  labelTextWhenNoError="Credit card number"
@@ -140,9 +133,6 @@ const PaymentFormCard = ({
140
133
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
141
134
  isNum
142
135
  autocompleteValue="cc-number"
143
- isRequired={getIsRequiredFromValidators(useCallback)(
144
- fields.creditCardNumber
145
- )}
146
136
  />
147
137
  <FormInputRow
148
138
  breakpoint={isMobile ? "1000rem" : "21rem"}
@@ -160,9 +150,6 @@ const PaymentFormCard = ({
160
150
  isNum
161
151
  removeFromValue={/\//} // removes "/" from browser autofill
162
152
  autocompleteValue="cc-exp"
163
- isRequired={getIsRequiredFromValidators(useCallback)(
164
- fields.expirationDate
165
- )}
166
153
  />
167
154
  <FormInput
168
155
  labelTextWhenNoError="CVV"
@@ -179,7 +166,6 @@ const PaymentFormCard = ({
179
166
  }
180
167
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
181
168
  autocompleteValue="cc-csc"
182
- isRequired={getIsRequiredFromValidators(useCallback)(fields.cvv)}
183
169
  />
184
170
  </FormInputRow>
185
171
  {!hideZipCode && (
@@ -198,9 +184,6 @@ const PaymentFormCard = ({
198
184
  showErrors={showErrors}
199
185
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
200
186
  autocompleteValue="billing postal-code"
201
- isRequired={getIsRequiredFromValidators(useCallback)(
202
- fields.zipCode
203
- )}
204
187
  />
205
188
  </Box>
206
189
  )}
@@ -123,8 +123,7 @@ const RadioSection = ({
123
123
  extraStyles={borderStyles}
124
124
  role="radio"
125
125
  aria-checked={openSection === section.id}
126
- disabled={section.disabled}
127
- required={section?.required}
126
+ aria-disabled={section.disabled}
128
127
  >
129
128
  <Stack childGap="0">
130
129
  <Box
@@ -167,8 +166,6 @@ const RadioSection = ({
167
166
  {!section.hideRadioButton && (
168
167
  <Box padding="0">
169
168
  <RadioButton
170
- role="radio"
171
- required={!!section?.required}
172
169
  id={`radio-input-${idString(section)}`}
173
170
  name={idString(section)}
174
171
  ariaDescribedBy={ariaDescribedBy}
@@ -49,11 +49,10 @@ const sections = [
49
49
  title: "New Card",
50
50
  content: <p>The form to add a credit card would go here.</p>,
51
51
  rightIconsLabel: cardIconsLabel,
52
- rightIcons: cardIcons,
53
- required: true
52
+ rightIcons: cardIcons
54
53
  },
55
- { id: "bar", title: "Bar", content: <div>Content 1</div>, required: true },
56
- { id: "baz", title: "Baz", content: <div>Content 2</div>, required: true }
54
+ { id: "bar", title: "Bar", content: <div>Content 1</div> },
55
+ { id: "baz", title: "Baz", content: <div>Content 2</div> }
57
56
  ];
58
57
 
59
58
  export const radioSection = () => {
@@ -19,25 +19,26 @@ const RadioButton = ({
19
19
  ariaDescribedBy = "",
20
20
  themeValues,
21
21
  ariaLabelledBy = "",
22
- ariaLabel = null,
23
- required = false
22
+ ariaLabel = null
24
23
  }) => {
25
24
  const buttonBorder = {
26
25
  onFocused: {
27
26
  borderColor: themeValues.activeColor,
28
- boxShadow: `0px 0px 4px 0px ${themeValues.activeColor}`
27
+ outline: `3px solid ${themeValues.activeColor}`,
28
+ outlineOffset: "2px"
29
29
  },
30
30
  offFocused: {
31
31
  borderColor: themeValues.activeColor,
32
- boxShadow: `0px 0px 4px 0px ${themeValues.activeColor}`
32
+ outline: `3px solid ${themeValues.activeColor}`,
33
+ outlineOffset: "2px"
33
34
  },
34
35
  on: {
35
36
  borderColor: themeValues.activeColor,
36
- boxShadow: "0px 0px 0px 0px #FFFFFF"
37
+ outline: "0"
37
38
  },
38
39
  off: {
39
40
  borderColor: themeValues.inactiveColor,
40
- boxShadow: "0px 0px 0px 0px #FFFFFF"
41
+ outline: "0"
41
42
  }
42
43
  };
43
44
 
@@ -92,14 +93,13 @@ const RadioButton = ({
92
93
  onClick={toggleRadio}
93
94
  aria-describedby={ariaDescribedBy}
94
95
  tabIndex="-1"
95
- required={required}
96
96
  {...extraProps}
97
97
  />
98
98
  <Motion
99
99
  borderWidth="1px"
100
100
  borderStyle="solid"
101
101
  borderRadius="12px"
102
- margin="4px 14px 4px 4px"
102
+ margin="6px 14px 6px 6px"
103
103
  height="24px"
104
104
  width="24px"
105
105
  variants={buttonBorder}
@@ -1,7 +1,7 @@
1
- import { MATISSE_BLUE, GREY_CHATEAU } from "../../../../constants/colors";
1
+ import { MATISSE_BLUE, STORM_GREY } from "../../../../constants/colors";
2
2
 
3
3
  const activeColor = `${MATISSE_BLUE}`;
4
- const inactiveColor = `${GREY_CHATEAU}`;
4
+ const inactiveColor = `${STORM_GREY}`;
5
5
 
6
6
  export const fallbackValues = {
7
7
  activeColor,