@thecb/components 10.7.2 → 10.7.3
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/dist/index.cjs.js +28 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +28 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +12 -0
- package/src/components/atoms/form-layouts/FormInput.js +10 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +2 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.state.js +2 -2
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/icons/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -238,6 +238,17 @@ const Dropdown = ({
|
|
|
238
238
|
}
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
+
const handleOnBlur = inputVal => {
|
|
242
|
+
const selectedRefExists =
|
|
243
|
+
selectedRef !== undefined && selectedRef.current !== null;
|
|
244
|
+
const inputRequired = options.required || isRequired;
|
|
245
|
+
const hasSelectedValue = value || selectedRefExists;
|
|
246
|
+
// Select the empty value to trigger a validation error if it's required.
|
|
247
|
+
if (inputRequired && !hasSelectedValue && inputVal === "") {
|
|
248
|
+
onSelect("");
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
241
252
|
useEffect(() => {
|
|
242
253
|
const selectedRefExists =
|
|
243
254
|
selectedRef !== undefined && selectedRef.current !== null;
|
|
@@ -357,6 +368,7 @@ const Dropdown = ({
|
|
|
357
368
|
setInputChangedByAutofill(true);
|
|
358
369
|
}
|
|
359
370
|
}}
|
|
371
|
+
onBlur={e => handleOnBlur(e.target.value)}
|
|
360
372
|
padding="12px 25px 12px 12px"
|
|
361
373
|
placeholder={getSelection()}
|
|
362
374
|
required={options.required || isRequired}
|
|
@@ -121,6 +121,7 @@ const FormInput = ({
|
|
|
121
121
|
}) => {
|
|
122
122
|
const [showPassword, setShowPassword] = useState(false);
|
|
123
123
|
const { isMobile } = useContext(ThemeContext);
|
|
124
|
+
|
|
124
125
|
const setValue = value => {
|
|
125
126
|
if (removeFromValue !== undefined) {
|
|
126
127
|
return fieldActions.set(value.replace(removeFromValue, ""));
|
|
@@ -128,6 +129,13 @@ const FormInput = ({
|
|
|
128
129
|
return fieldActions.set(value);
|
|
129
130
|
};
|
|
130
131
|
|
|
132
|
+
const handleOnBlur = value => {
|
|
133
|
+
// Sets the empty value to trigger a validation error if it's required.
|
|
134
|
+
if (isRequired && value === "") {
|
|
135
|
+
setValue("");
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
131
139
|
return (
|
|
132
140
|
<Stack childGap="0.25rem">
|
|
133
141
|
<Box padding="0">
|
|
@@ -204,6 +212,7 @@ const FormInput = ({
|
|
|
204
212
|
(field.hasErrors && showErrors)
|
|
205
213
|
}
|
|
206
214
|
onChange={value => setValue(value)}
|
|
215
|
+
onBlur={e => handleOnBlur(e.target.value)}
|
|
207
216
|
type={type}
|
|
208
217
|
value={field.rawValue}
|
|
209
218
|
pattern={isNum ? "[0-9]*" : ""}
|
|
@@ -231,6 +240,7 @@ const FormInput = ({
|
|
|
231
240
|
(field.hasErrors && showErrors)
|
|
232
241
|
}
|
|
233
242
|
onChange={e => setValue(e.target.value)}
|
|
243
|
+
onBlur={e => handleOnBlur(e.target.value)}
|
|
234
244
|
type={type === "password" && showPassword ? "text" : type}
|
|
235
245
|
value={field.rawValue}
|
|
236
246
|
pattern={isNum ? "[0-9]*" : ""}
|
|
@@ -49,6 +49,7 @@ const PaymentFormACH = ({
|
|
|
49
49
|
[isRoutingNumber.error]: "Invalid routing number"
|
|
50
50
|
};
|
|
51
51
|
const confirmRoutingNumberErrors = {
|
|
52
|
+
[required.error]: "Confirm routing number is required",
|
|
52
53
|
[matchesField.error]:
|
|
53
54
|
"Confirm routing number field must match routing number"
|
|
54
55
|
};
|
|
@@ -57,6 +58,7 @@ const PaymentFormACH = ({
|
|
|
57
58
|
[hasLength.error]: "Account number must be between 5 and 17 digits"
|
|
58
59
|
};
|
|
59
60
|
const confirmAccountNumberErrors = {
|
|
61
|
+
[required.error]: "Confirm account number is required",
|
|
60
62
|
[matchesField.error]:
|
|
61
63
|
"Confirm account number field must match account number"
|
|
62
64
|
};
|
|
@@ -16,7 +16,7 @@ const formConfig = {
|
|
|
16
16
|
constraints: [onlyIntegers(), hasLength(0, 9)]
|
|
17
17
|
},
|
|
18
18
|
confirmRoutingNumber: {
|
|
19
|
-
validators: [matchesField("routingNumber")],
|
|
19
|
+
validators: [required(), 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")],
|
|
27
|
+
validators: [required(), matchesField("accountNumber")],
|
|
28
28
|
constraints: [onlyIntegers(), hasLength(0, 17)]
|
|
29
29
|
},
|
|
30
30
|
accountType: {
|
|
Binary file
|
|
Binary file
|