@thecb/components 9.1.6-beta.0 → 9.1.7-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.1.6-beta.0",
3
+ "version": "9.1.7-beta.0",
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;
@@ -12,11 +12,11 @@ import styled from "styled-components";
12
12
  import "core-js/proposals/relative-indexing-method";
13
13
 
14
14
  import {
15
- WHITE,
15
+ ERROR_COLOR,
16
16
  GREY_CHATEAU,
17
- STORM_GREY,
18
17
  MINESHAFT_GREY,
19
- ERROR_COLOR
18
+ STORM_GREY,
19
+ WHITE
20
20
  } from "../../../constants/colors";
21
21
  import { fallbackValues } from "./Dropdown.theme";
22
22
  import { themeComponent } from "../../../util/themeUtils";
@@ -55,10 +55,8 @@ const DropdownContentWrapper = styled.div`
55
55
  `;
56
56
 
57
57
  const DropdownItemWrapper = styled.li`
58
- background-color: ${({ selected, themeValues }) =>
59
- selected ? themeValues.selectedColor : WHITE};
60
58
  text-align: start;
61
- border-width: 0px;
59
+ border-width: 2px;
62
60
  border-color: transparent;
63
61
  box-shadow: none;
64
62
  padding: 1rem;
@@ -67,6 +65,23 @@ const DropdownItemWrapper = styled.li`
67
65
  list-style: none;
68
66
  cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
69
67
 
68
+ &:hover {
69
+ border-color: themeValues.selectedColor;
70
+ }
71
+ &:focus {
72
+ outline: none;
73
+ border-color: themeValues.selectedColor;
74
+ }
75
+ `;
76
+ // ${({ selected, themeValues }) =>
77
+ // selected ? themeValues.selectedColor : TRANSPARENT};
78
+ const DropdownItemBorder = styled.div`
79
+ background-color: ${({ selected, themeValues }) =>
80
+ selected ? themeValues.selectedColor : WHITE};
81
+ border-width: 2px;
82
+ border-color: white;
83
+ width: 100%;
84
+
70
85
  &:hover {
71
86
  background-color: ${({ selected, disabled, themeValues }) =>
72
87
  selected
@@ -105,8 +120,7 @@ const Dropdown = ({
105
120
  ariaDescribedby,
106
121
  autocompleteValue, // browser autofill value, like country-name
107
122
  smoothScroll = true,
108
- ariaInvalid = false,
109
- isRequired = false
123
+ ariaInvalid = false
110
124
  }) => {
111
125
  const [inputValue, setInputValue] = useState("");
112
126
  const [optionsState, setOptionsState] = useState([]);
@@ -329,7 +343,7 @@ const Dropdown = ({
329
343
  }}
330
344
  padding="12px"
331
345
  placeholder={getSelection()}
332
- required={options.required || isRequired}
346
+ required={options.required}
333
347
  role="combobox"
334
348
  themeValues={themeValues}
335
349
  title={hasTitles ? getSelection() : null}
@@ -386,27 +400,29 @@ const Dropdown = ({
386
400
  role="option"
387
401
  onFocus={() => setFocusedRef(optionRefs.current[i])}
388
402
  >
389
- <Text
390
- variant="p"
391
- color={
392
- choice.value === value
393
- ? WHITE
394
- : disabledValues.includes(choice.value)
395
- ? STORM_GREY
396
- : MINESHAFT_GREY
397
- }
398
- extraStyles={`padding-left: 16px;
399
- cursor: ${
400
- disabledValues.includes(choice.value)
401
- ? "default"
402
- : "pointer"
403
- };
404
- white-space: nowrap;
405
- overflow: hidden;
406
- text-overflow: ellipsis;`}
407
- >
408
- {choice.text}
409
- </Text>
403
+ <DropdownItemBorder selected={choice.value === value}>
404
+ <Text
405
+ variant="p"
406
+ color={
407
+ choice.value === value
408
+ ? WHITE
409
+ : disabledValues.includes(choice.value)
410
+ ? STORM_GREY
411
+ : MINESHAFT_GREY
412
+ }
413
+ extraStyles={`padding-left: 16px;
414
+ cursor: ${
415
+ disabledValues.includes(choice.value)
416
+ ? "default"
417
+ : "pointer"
418
+ };
419
+ white-space: nowrap;
420
+ overflow: hidden;
421
+ text-overflow: ellipsis;`}
422
+ >
423
+ {choice.text}
424
+ </Text>
425
+ </DropdownItemBorder>
410
426
  </DropdownItemWrapper>
411
427
  );
412
428
  })}
@@ -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
  )}
@@ -47,8 +47,7 @@ const RadioSection = ({
47
47
  initiallyOpen = true,
48
48
  openHeight = "auto",
49
49
  containerStyles = "",
50
- ariaDescribedBy,
51
- isRequired = false
50
+ ariaDescribedBy
52
51
  }) => {
53
52
  const handleKeyDown = (id, e) => {
54
53
  if (e?.keyCode === 13 || e?.keyCode === 32) {
@@ -106,7 +105,7 @@ const RadioSection = ({
106
105
  borderRadius="4px"
107
106
  extraStyles={containerStyles}
108
107
  >
109
- <Stack childGap="0" role="radiogroup" required={isRequired}>
108
+ <Stack childGap="0" role="radiogroup">
110
109
  {sections
111
110
  .filter(section => !section.hidden)
112
111
  .map(section => (
@@ -124,8 +123,7 @@ const RadioSection = ({
124
123
  extraStyles={borderStyles}
125
124
  role="radio"
126
125
  aria-checked={openSection === section.id}
127
- disabled={section.disabled}
128
- required={section?.required}
126
+ aria-disabled={section.disabled}
129
127
  >
130
128
  <Stack childGap="0">
131
129
  <Box
@@ -168,8 +166,6 @@ const RadioSection = ({
168
166
  {!section.hideRadioButton && (
169
167
  <Box padding="0">
170
168
  <RadioButton
171
- role="radio"
172
- required={!!section?.required}
173
169
  id={`radio-input-${idString(section)}`}
174
170
  name={idString(section)}
175
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,8 +19,7 @@ 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: {
@@ -94,7 +93,6 @@ const RadioButton = ({
94
93
  onClick={toggleRadio}
95
94
  aria-describedby={ariaDescribedBy}
96
95
  tabIndex="-1"
97
- required={required}
98
96
  {...extraProps}
99
97
  />
100
98
  <Motion