@thecb/components 9.2.4-beta.8 → 9.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.2.4-beta.8",
3
+ "version": "9.2.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,6 +10,7 @@ const CountryDropdown = ({
10
10
  fieldActions,
11
11
  showErrors,
12
12
  onChange,
13
+ isRequired = false,
13
14
  dataQa = null
14
15
  }) => (
15
16
  <FormSelect
@@ -22,6 +23,7 @@ const CountryDropdown = ({
22
23
  showErrors={showErrors}
23
24
  onChange={onChange}
24
25
  autocompleteValue="country-name"
26
+ isRequired={isRequired}
25
27
  />
26
28
  );
27
29
  export default CountryDropdown;
@@ -133,7 +133,8 @@ const Dropdown = ({
133
133
  ariaDescribedby,
134
134
  autocompleteValue, // browser autofill value, like country-name
135
135
  smoothScroll = true,
136
- ariaInvalid = false
136
+ ariaInvalid = false,
137
+ isRequired = false
137
138
  }) => {
138
139
  const [inputValue, setInputValue] = useState("");
139
140
  const [optionsState, setOptionsState] = useState([]);
@@ -262,13 +263,15 @@ const Dropdown = ({
262
263
  useEffect(() => {
263
264
  if (autoEraseTypeAhead) {
264
265
  clearTimeout(timer);
265
- setTimer(setTimeout(() => setInputValue(""), 3000));
266
+ setTimer(setTimeout(() => setInputValue(""), 20000));
266
267
  }
268
+
267
269
  setFilteredOptions(
268
270
  options.filter(
269
271
  option =>
270
- option.value.toLowerCase().startsWith(inputValue.toLowerCase()) ||
271
- option.text.toLowerCase().startsWith(inputValue.toLowerCase())
272
+ option?.value?.toLowerCase()?.indexOf(inputValue?.toLowerCase()) >=
273
+ 0 ||
274
+ option.text?.toLowerCase()?.indexOf(inputValue?.toLowerCase()) >= 0
272
275
  )
273
276
  );
274
277
  }, [inputValue]);
@@ -356,7 +359,7 @@ const Dropdown = ({
356
359
  }}
357
360
  padding="12px"
358
361
  placeholder={getSelection()}
359
- required={options.required}
362
+ required={options.required || isRequired}
360
363
  role="combobox"
361
364
  themeValues={themeValues}
362
365
  title={hasTitles ? getSelection() : null}
@@ -116,6 +116,7 @@ const FormInput = ({
116
116
  extraStyles,
117
117
  removeFromValue, // regex of characters to remove before setting value
118
118
  dataQa = null,
119
+ isRequired = false,
119
120
  ...props
120
121
  }) => {
121
122
  const [showPassword, setShowPassword] = useState(false);
@@ -221,6 +222,7 @@ const FormInput = ({
221
222
  $extraStyles={extraStyles}
222
223
  data-qa={dataQa || labelTextWhenNoError}
223
224
  autoComplete={autocompleteValue}
225
+ required={isRequired}
224
226
  {...props}
225
227
  />
226
228
  ) : (
@@ -247,6 +249,7 @@ const FormInput = ({
247
249
  $extraStyles={extraStyles}
248
250
  data-qa={dataQa || labelTextWhenNoError}
249
251
  autoComplete={autocompleteValue}
252
+ required={isRequired}
250
253
  {...props}
251
254
  />
252
255
  )}
@@ -24,7 +24,8 @@ 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
27
+ widthFitOptions = false,
28
+ isRequired = false
28
29
  }) => {
29
30
  const [open, setOpen] = useState(false);
30
31
  const dropdownRef = useRef(null);
@@ -94,6 +95,7 @@ const FormSelect = ({
94
95
  disabled={disabled}
95
96
  autocompleteValue={autocompleteValue}
96
97
  smoothScroll={smoothScroll}
98
+ isRequired={isRequired}
97
99
  />
98
100
  <Stack direction="row" justify="space-between">
99
101
  {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
@@ -9,7 +9,8 @@ const FormStateDropdown = ({
9
9
  field,
10
10
  fieldActions,
11
11
  showErrors,
12
- countryCode
12
+ countryCode,
13
+ isRequired = false
13
14
  }) => {
14
15
  const placeholder =
15
16
  countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
@@ -23,6 +24,7 @@ const FormStateDropdown = ({
23
24
  errorMessages={errorMessages}
24
25
  showErrors={showErrors}
25
26
  autocompleteValue="address-level1"
27
+ isRequired={isRequired}
26
28
  />
27
29
  );
28
30
  };
@@ -71,6 +71,7 @@ const AddressForm = ({
71
71
  }}
72
72
  showErrors={showErrors}
73
73
  dataQa="Country"
74
+ isRequired={true}
74
75
  />
75
76
  <FormInput
76
77
  labelTextWhenNoError="Address"
@@ -81,6 +82,7 @@ const AddressForm = ({
81
82
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
82
83
  autocompleteValue="address-line1"
83
84
  dataQa="Address"
85
+ isRequired={true}
84
86
  />
85
87
  <FormInput
86
88
  labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
@@ -100,6 +102,7 @@ const AddressForm = ({
100
102
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
101
103
  autocompleteValue="address-level2"
102
104
  dataQa="City"
105
+ isRequired={true}
103
106
  />
104
107
  <StateProvinceDropdown
105
108
  labelTextWhenNoError={isUS ? "State" : "State or Province"}
@@ -110,6 +113,7 @@ const AddressForm = ({
110
113
  showErrors={showErrors}
111
114
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
112
115
  dataQa="State or Province"
116
+ isRequired={true}
113
117
  />
114
118
  <FormInput
115
119
  isNum={isUS}
@@ -122,6 +126,7 @@ const AddressForm = ({
122
126
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
123
127
  autocompleteValue="postal-code"
124
128
  dataQa="Zip code"
129
+ isRequired={true}
125
130
  />
126
131
  {showWalletCheckbox && (
127
132
  <Checkbox
@@ -19,7 +19,8 @@ const EmailForm = ({
19
19
  handleSubmit = noop,
20
20
  showWalletCheckbox,
21
21
  saveToWallet,
22
- walletCheckboxMarked
22
+ walletCheckboxMarked,
23
+ isRequired = false
23
24
  }) => {
24
25
  if (clearOnDismount) {
25
26
  useEffect(() => () => actions.form.clear(), []);
@@ -48,6 +49,7 @@ const EmailForm = ({
48
49
  isEmail
49
50
  autocompleteValue="email"
50
51
  dataQa="Email address"
52
+ isRequired={isRequired}
51
53
  />
52
54
  {showWalletCheckbox && (
53
55
  <Checkbox
@@ -76,6 +76,7 @@ const PaymentFormACH = ({
76
76
  showErrors={showErrors}
77
77
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
78
78
  autocompleteValue="name"
79
+ isRequired={true}
79
80
  />
80
81
  <FormInput
81
82
  labelTextWhenNoError="Routing number"
@@ -97,6 +98,7 @@ const PaymentFormACH = ({
97
98
  />
98
99
  )}
99
100
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
101
+ isRequired={true}
100
102
  />
101
103
  <FormInput
102
104
  labelTextWhenNoError="Confirm routing number"
@@ -107,6 +109,7 @@ const PaymentFormACH = ({
107
109
  showErrors={showErrors}
108
110
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
109
111
  isNum
112
+ isRequired={true}
110
113
  />
111
114
  <FormInput
112
115
  labelTextWhenNoError="Account number"
@@ -128,6 +131,7 @@ const PaymentFormACH = ({
128
131
  />
129
132
  )}
130
133
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
134
+ isRequired={true}
131
135
  />
132
136
  <FormInput
133
137
  labelTextWhenNoError="Confirm account number"
@@ -137,6 +141,7 @@ const PaymentFormACH = ({
137
141
  fieldActions={actions.fields.confirmAccountNumber}
138
142
  showErrors={showErrors}
139
143
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
144
+ isRequired={true}
140
145
  isNum
141
146
  />
142
147
  {allowBankAccountType && (
@@ -152,6 +157,7 @@ const PaymentFormACH = ({
152
157
  showErrors={showErrors}
153
158
  errorMessages={accountTypeErrors}
154
159
  field={fields.accountType}
160
+ isRequired={true}
155
161
  />
156
162
  )}
157
163
  {!hideDefaultPayment && (
@@ -121,6 +121,7 @@ const PaymentFormCard = ({
121
121
  showErrors={showErrors}
122
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
123
123
  autocompleteValue="cc-name"
124
+ isRequired={true}
124
125
  />
125
126
  <FormInput
126
127
  labelTextWhenNoError="Credit card number"
@@ -133,6 +134,7 @@ const PaymentFormCard = ({
133
134
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
134
135
  isNum
135
136
  autocompleteValue="cc-number"
137
+ isRequired={true}
136
138
  />
137
139
  <FormInputRow
138
140
  breakpoint={isMobile ? "1000rem" : "21rem"}
@@ -150,6 +152,7 @@ const PaymentFormCard = ({
150
152
  isNum
151
153
  removeFromValue={/\//} // removes "/" from browser autofill
152
154
  autocompleteValue="cc-exp"
155
+ isRequired={true}
153
156
  />
154
157
  <FormInput
155
158
  labelTextWhenNoError="CVV"
@@ -166,6 +169,7 @@ const PaymentFormCard = ({
166
169
  }
167
170
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
168
171
  autocompleteValue="cc-csc"
172
+ isRequired={true}
169
173
  />
170
174
  </FormInputRow>
171
175
  {!hideZipCode && (
@@ -184,6 +188,7 @@ const PaymentFormCard = ({
184
188
  showErrors={showErrors}
185
189
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
186
190
  autocompleteValue="billing postal-code"
191
+ isRequired={true}
187
192
  />
188
193
  </Box>
189
194
  )}
@@ -19,7 +19,8 @@ const PhoneForm = ({
19
19
  handleSubmit = noop,
20
20
  showWalletCheckbox,
21
21
  saveToWallet,
22
- walletCheckboxMarked
22
+ walletCheckboxMarked,
23
+ isRequired = false
23
24
  }) => {
24
25
  if (clearOnDismount) {
25
26
  useEffect(() => () => actions.form.clear(), []);
@@ -43,6 +44,7 @@ const PhoneForm = ({
43
44
  autocompleteValue="tel-national"
44
45
  dataQa="Phone number"
45
46
  isNum={true}
47
+ isRequired={isRequired}
46
48
  />
47
49
  {showWalletCheckbox && (
48
50
  <Checkbox
@@ -106,7 +106,11 @@ const RadioSection = ({
106
106
  borderRadius="4px"
107
107
  extraStyles={containerStyles}
108
108
  >
109
- <Stack childGap="0" role="radiogroup" aria-required={isSectionRequired}>
109
+ <Stack
110
+ childGap="0"
111
+ aria-role="radiogroup"
112
+ aria-required={isSectionRequired}
113
+ >
110
114
  {sections
111
115
  .filter(section => !section.hidden)
112
116
  .map(section => (
@@ -125,7 +129,7 @@ const RadioSection = ({
125
129
  role="radio"
126
130
  aria-checked={openSection === section.id}
127
131
  aria-disabled={section.disabled}
128
- aria-required={!!section?.required}
132
+ aria-required={section?.required}
129
133
  >
130
134
  <Stack childGap="0">
131
135
  <Box
@@ -179,7 +183,7 @@ const RadioSection = ({
179
183
  : () => toggleOpenSection(section.id)
180
184
  }
181
185
  tabIndex="-1"
182
- aria-required={!!section?.required}
186
+ isRequired={section?.required}
183
187
  />
184
188
  </Box>
185
189
  )}
@@ -20,7 +20,7 @@ const RadioButton = ({
20
20
  themeValues,
21
21
  ariaLabelledBy = "",
22
22
  ariaLabel = null,
23
- ...rest
23
+ isRequired = false
24
24
  }) => {
25
25
  const buttonBorder = {
26
26
  onFocused: {
@@ -65,7 +65,7 @@ const RadioButton = ({
65
65
  width: "0px"
66
66
  }
67
67
  };
68
- const extraProps = rest?.length ? rest : {};
68
+ const extraProps = {};
69
69
  if (ariaLabelledBy && ariaLabelledBy.length) {
70
70
  extraProps["aria-labelledby"] = ariaLabelledBy;
71
71
  } else if (ariaLabel && ariaLabel !== null) {
@@ -94,6 +94,7 @@ const RadioButton = ({
94
94
  onClick={toggleRadio}
95
95
  aria-describedby={ariaDescribedBy}
96
96
  tabIndex="-1"
97
+ required={isRequired}
97
98
  {...extraProps}
98
99
  />
99
100
  <Motion