@thecb/components 2.2.1 → 2.3.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/.tool-versions +1 -0
- package/dist/index.cjs.js +30904 -3033
- package/package.json +15 -35
- package/rollup.config.js +3 -1
- package/src/components/atoms/button-with-action/ButtonWithAction.js +25 -4
- package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +64 -234
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.js +53 -0
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.theme.js +9 -0
- package/src/components/atoms/formatted-credit-card/index.js +3 -0
- package/src/components/atoms/icons/AccountNumberImage.js +95 -0
- package/src/components/atoms/icons/BankIcon.js +82 -0
- package/src/components/atoms/icons/CheckmarkIcon.js +55 -0
- package/src/components/atoms/icons/GenericCard.js +39 -0
- package/src/components/atoms/icons/PaymentIcon.js +50 -0
- package/src/components/atoms/icons/RoutingNumberImage.js +95 -0
- package/src/components/atoms/icons/index.js +14 -1
- package/src/components/atoms/index.js +3 -0
- package/src/components/atoms/jumbo/Jumbo.js +76 -0
- package/src/components/atoms/jumbo/index.js +3 -0
- package/src/components/atoms/loading/Loading.js +17 -0
- package/src/components/atoms/loading/index.js +3 -0
- package/src/components/atoms/nav-header/NavHeader.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.js +75 -0
- package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.theme.js +24 -0
- package/src/components/molecules/account-and-routing-modal/index.js +3 -0
- package/src/components/molecules/address-form/AddressForm.js +2 -1
- package/src/components/molecules/address-form/index.js +6 -6
- package/src/components/molecules/change-password-form/ChangePasswordForm.js +2 -1
- package/src/components/molecules/change-password-form/index.js +1 -1
- package/src/components/molecules/edit-name-form/EditNameForm.js +2 -1
- package/src/components/molecules/edit-name-form/index.js +1 -1
- package/src/components/molecules/editable-list/EditableList.js +139 -0
- package/src/components/molecules/editable-list/EditableList.styled.js +31 -0
- package/src/components/molecules/editable-list/index.js +3 -0
- package/src/components/molecules/editable-table/EditableTable.js +30 -0
- package/src/components/molecules/editable-table/EditableTable.styled.js +80 -0
- package/src/components/molecules/editable-table/TableListItem.js +64 -0
- package/src/components/molecules/editable-table/index.js +4 -0
- package/src/components/molecules/email-form/EmailForm.js +2 -1
- package/src/components/molecules/email-form/index.js +1 -1
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.js +2 -1
- package/src/components/molecules/forgot-password-form/index.js +1 -1
- package/src/components/molecules/index.js +5 -0
- package/src/components/molecules/login-form/LoginForm.js +2 -1
- package/src/components/molecules/login-form/index.js +1 -1
- package/src/components/molecules/module/Module.js +1 -3
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +73 -0
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +51 -0
- package/src/components/molecules/partial-amount-form/index.js +4 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +189 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.state.js +38 -0
- package/src/components/molecules/payment-form-ach/index.js +11 -0
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +132 -0
- package/src/components/molecules/payment-form-card/PaymentFormCard.state.js +39 -0
- package/src/components/molecules/payment-form-card/index.js +11 -0
- package/src/components/molecules/phone-form/PhoneForm.js +2 -1
- package/src/components/molecules/phone-form/index.js +1 -1
- package/src/components/molecules/registration-form/RegistrationForm.js +2 -1
- package/src/components/molecules/registration-form/index.js +1 -1
- package/src/components/molecules/reset-password-form/ResetPasswordForm.js +3 -1
- package/src/components/molecules/reset-password-form/index.js +1 -1
- package/src/constants/index.js +2 -0
- package/src/index.js +2 -1
- package/src/util/formats.js +54 -2
- package/src/util/general.js +27 -4
- package/src/util/index.js +2 -0
- package/src/util/inputValidationUtils.js +0 -167
- package/stats.html +2652 -0
- package/src/util/router-utils.js +0 -23
package/src/util/formats.js
CHANGED
|
@@ -12,7 +12,7 @@ export const phoneFormats = [
|
|
|
12
12
|
"(___) ___-_",
|
|
13
13
|
"(___) ___-__",
|
|
14
14
|
"(___) ___-___",
|
|
15
|
-
"(___) ___-____"
|
|
15
|
+
"(___) ___-____"
|
|
16
16
|
];
|
|
17
17
|
|
|
18
18
|
const zipFormats = [
|
|
@@ -25,6 +25,58 @@ const zipFormats = [
|
|
|
25
25
|
"______",
|
|
26
26
|
"_____-__",
|
|
27
27
|
"_____-___",
|
|
28
|
-
"_____-____"
|
|
28
|
+
"_____-____"
|
|
29
29
|
];
|
|
30
|
+
|
|
31
|
+
const creditCardFormats = [
|
|
32
|
+
"",
|
|
33
|
+
"_",
|
|
34
|
+
"__",
|
|
35
|
+
"___",
|
|
36
|
+
"____",
|
|
37
|
+
"____ _",
|
|
38
|
+
"____ __",
|
|
39
|
+
"____ ___",
|
|
40
|
+
"____ ____",
|
|
41
|
+
"____ ____ _",
|
|
42
|
+
"____ ____ __",
|
|
43
|
+
"____ ____ ___",
|
|
44
|
+
"____ ____ ____",
|
|
45
|
+
"____ ____ ____ _",
|
|
46
|
+
"____ ____ ____ __",
|
|
47
|
+
"____ ____ ____ ___",
|
|
48
|
+
"____ ____ ____ ____"
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export const moneyFormats = [
|
|
52
|
+
"",
|
|
53
|
+
"$0.0_",
|
|
54
|
+
"$0.__",
|
|
55
|
+
"$_.__",
|
|
56
|
+
"$__.__",
|
|
57
|
+
"$___.__",
|
|
58
|
+
"$_,___.__",
|
|
59
|
+
"$__,___.__",
|
|
60
|
+
"$___,___.__",
|
|
61
|
+
"$_,___,___.__",
|
|
62
|
+
"$__,___,___.__",
|
|
63
|
+
"$___,___,___.__",
|
|
64
|
+
"$_,___,___,___.__",
|
|
65
|
+
"$__,___,___,___.__",
|
|
66
|
+
"$___,___,___,___.__",
|
|
67
|
+
"$_,___,___,___,___.__"
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
export const expirationDateFormats = ["", "_", "__/", "__/_", "__/__"];
|
|
71
|
+
|
|
30
72
|
export const zipFormat = createFormat(zipFormats, formatDelimiter);
|
|
73
|
+
export const creditCardFormat = createFormat(
|
|
74
|
+
creditCardFormats,
|
|
75
|
+
formatDelimiter
|
|
76
|
+
);
|
|
77
|
+
export const expirationDateFormat = createFormat(
|
|
78
|
+
expirationDateFormats,
|
|
79
|
+
formatDelimiter
|
|
80
|
+
);
|
|
81
|
+
export const phoneFormat = createFormat(phoneFormats, formatDelimiter);
|
|
82
|
+
export const moneyFormat = createFormat(moneyFormats, formatDelimiter);
|
package/src/util/general.js
CHANGED
|
@@ -2,14 +2,37 @@ import numeral from "numeral";
|
|
|
2
2
|
|
|
3
3
|
export const noop = () => {};
|
|
4
4
|
|
|
5
|
-
const formatMoneyString =
|
|
6
|
-
const convertCentsToMoneyDecimal =
|
|
7
|
-
export const displayCurrency =
|
|
5
|
+
const formatMoneyString = s => numeral(s).format("$0,0.00");
|
|
6
|
+
const convertCentsToMoneyDecimal = n => (n / 100).toFixed(2);
|
|
7
|
+
export const displayCurrency = cents =>
|
|
8
8
|
formatMoneyString(convertCentsToMoneyDecimal(cents));
|
|
9
9
|
|
|
10
|
+
export const convertCentsToMoneyInt = n => (n / 100).toFixed(0);
|
|
11
|
+
|
|
10
12
|
export const safeChildren = (children, replacement = []) => {
|
|
11
13
|
if (children && children instanceof Array) {
|
|
12
|
-
return children.map(
|
|
14
|
+
return children.map(child => (!child ? replacement : child));
|
|
13
15
|
}
|
|
14
16
|
return !children ? replacement : children;
|
|
15
17
|
};
|
|
18
|
+
|
|
19
|
+
export const generateClickHandler = (form, handleErrors, submitForm) => e => {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const formHasError = Object.values(form.fields).reduce(
|
|
22
|
+
(acc, curr) => acc || curr.hasErrors,
|
|
23
|
+
false
|
|
24
|
+
);
|
|
25
|
+
return formHasError ? handleErrors() : submitForm();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const checkCardBrand = number => {
|
|
29
|
+
if (/^6011/.test(number)) {
|
|
30
|
+
return "DISCOVER";
|
|
31
|
+
} else if (/^5[1-5]/.test(number)) {
|
|
32
|
+
return "MASTERCARD";
|
|
33
|
+
} else if (/^4/.test(number)) {
|
|
34
|
+
return "VISA";
|
|
35
|
+
} else if (/^3[4,7]/.test(number)) {
|
|
36
|
+
return "AMEX";
|
|
37
|
+
} else return "UNKNOWN";
|
|
38
|
+
};
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import * as S from "sanctuary";
|
|
2
|
-
import * as $ from "sanctuary-def";
|
|
3
1
|
import * as R from "ramda";
|
|
4
2
|
|
|
5
|
-
// FormInput :: { form :: Object String any, keyName :: String }
|
|
6
|
-
|
|
7
|
-
// String -> Maybe String
|
|
8
|
-
const getsMaybeString = keyName => S.gets(S.is($.String))([keyName, "value"]);
|
|
9
|
-
|
|
10
|
-
// String, String, Regex -> FormInput -> Either String String
|
|
11
|
-
const regexTest = (keyName, errorMsg, regex) =>
|
|
12
|
-
S.pipe([
|
|
13
|
-
getsMaybeString(keyName),
|
|
14
|
-
S.maybeToEither("Invalid string entered"),
|
|
15
|
-
S.chain(string =>
|
|
16
|
-
S.test(regex)(string) ? S.Right(string) : S.Left(errorMsg)
|
|
17
|
-
)
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
3
|
// Constants to reprsent input error types
|
|
21
4
|
export const MIN_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
22
5
|
export const MAX_LENGTH_ERROR = "max_length_error";
|
|
@@ -105,153 +88,3 @@ export const getInputState = (
|
|
|
105
88
|
}
|
|
106
89
|
return INPUT_STATE_VALID;
|
|
107
90
|
};
|
|
108
|
-
|
|
109
|
-
// Number -> FormInput -> Either String String
|
|
110
|
-
export const stringHasMinLength = minLength => ({ form, keyName }) =>
|
|
111
|
-
S.pipe([
|
|
112
|
-
getsMaybeString(keyName),
|
|
113
|
-
S.maybeToEither("Invalid string entered"),
|
|
114
|
-
S.chain(string =>
|
|
115
|
-
string.length >= minLength ? S.Right(string) : S.Left(MIN_LENGTH_ERROR)
|
|
116
|
-
)
|
|
117
|
-
])(form);
|
|
118
|
-
|
|
119
|
-
// Number -> FormInput -> Either String String
|
|
120
|
-
// This function is INCLUSIVE of the maxLength arg supplied to it
|
|
121
|
-
export const stringHasMaxLength = maxLength => ({ form, keyName }) =>
|
|
122
|
-
S.pipe([
|
|
123
|
-
getsMaybeString(keyName),
|
|
124
|
-
S.maybeToEither("Invalid string entered"),
|
|
125
|
-
S.chain(string =>
|
|
126
|
-
string.length <= maxLength ? S.Right(string) : S.Left(MAX_LENGTH_ERROR)
|
|
127
|
-
)
|
|
128
|
-
])(form);
|
|
129
|
-
|
|
130
|
-
// Number -> FormInput -> Either String String
|
|
131
|
-
export const stringHasExactLength = exactLength => ({ form, keyName }) =>
|
|
132
|
-
S.pipe([
|
|
133
|
-
getsMaybeString(keyName),
|
|
134
|
-
S.maybeToEither("Invalid string entered"),
|
|
135
|
-
S.chain(string =>
|
|
136
|
-
string.length == exactLength
|
|
137
|
-
? S.Right(string)
|
|
138
|
-
: S.Left(EXACT_LENGTH_ERROR)
|
|
139
|
-
)
|
|
140
|
-
])(form);
|
|
141
|
-
|
|
142
|
-
// Array(Number) -> FormInput -> Either String String
|
|
143
|
-
export const stringHasMultipleValidLengths = validLengths => ({
|
|
144
|
-
form,
|
|
145
|
-
keyName
|
|
146
|
-
}) =>
|
|
147
|
-
S.pipe([
|
|
148
|
-
getsMaybeString(keyName),
|
|
149
|
-
S.maybeToEither("Form is missing key or value is not a string"),
|
|
150
|
-
S.chain(string =>
|
|
151
|
-
R.contains(string.length, validLengths)
|
|
152
|
-
? S.Right(string)
|
|
153
|
-
: S.Left(MULTIPLE_LENGTHS_ERROR)
|
|
154
|
-
)
|
|
155
|
-
])(form);
|
|
156
|
-
|
|
157
|
-
// FormInput -> Either String String
|
|
158
|
-
/* NOTE: this is not a foolproof email validation check
|
|
159
|
-
It will likely fail on edge cases such as " "@foo.com
|
|
160
|
-
It also cannot tell you if the particular email entered is valid for the given domain
|
|
161
|
-
Or if the email account actually exists
|
|
162
|
-
Only use this to help indicate to a user that they may have entered their email incorrectly
|
|
163
|
-
Real validation should be accomplished on the server by sending an email to
|
|
164
|
-
the provided email address
|
|
165
|
-
*/
|
|
166
|
-
export const isProbablyAnEmail = ({ form, keyName }) =>
|
|
167
|
-
regexTest(keyName, EMAIL_ERROR, /^[^\s@]+@[^\s@]+\.[^\s@]+$/)(form);
|
|
168
|
-
|
|
169
|
-
// FormInput -> Either String String
|
|
170
|
-
export const stringHasNumber = ({ form, keyName }) =>
|
|
171
|
-
regexTest(keyName, HAS_NUMBER_ERROR, /[0-9]/)(form);
|
|
172
|
-
|
|
173
|
-
// FormInput -> Either String String
|
|
174
|
-
export const stringHasUppercaseLetter = ({ form, keyName }) =>
|
|
175
|
-
regexTest(keyName, HAS_UPPERCASE_LETTER_ERROR, /[A-Z]/)(form);
|
|
176
|
-
|
|
177
|
-
// FormInput -> Either String String
|
|
178
|
-
export const stringHasLowercaseLetter = ({ form, keyName }) =>
|
|
179
|
-
regexTest(keyName, HAS_LOWERCASE_LETTER_ERROR, /[a-z]/)(form);
|
|
180
|
-
|
|
181
|
-
// FormInput -> Either String String
|
|
182
|
-
export const stringHasSpecialCharacter = ({ form, keyName }) =>
|
|
183
|
-
regexTest(keyName, HAS_SPECIAL_CHARACTER_ERROR, /[!@#$%^&*.?]/)(form);
|
|
184
|
-
|
|
185
|
-
// FormInput -> Either String String
|
|
186
|
-
export const stringIsOnlyNumbers = ({ form, keyName }) =>
|
|
187
|
-
regexTest(keyName, ONLY_NUMBERS_ERROR, /^[0-9]+$/)(form);
|
|
188
|
-
|
|
189
|
-
// FormInput -> Either String String
|
|
190
|
-
export const stringIsOnlyLetters = ({ form, keyName }) =>
|
|
191
|
-
regexTest(keyName, ONLY_LETTERS_ERROR, /^[a-zA-Z]+$/)(form);
|
|
192
|
-
|
|
193
|
-
// fieldIsRequired asks for only one character,
|
|
194
|
-
// which can be a letter (a-z) or (A-Z), a digit (0-9), or one of the special characters (!@#$%^&*.?)
|
|
195
|
-
// If you need only letters or numbers use one of the more specific string checks above
|
|
196
|
-
// If you need the string to exceed a specificed length, use stringHasMinLength
|
|
197
|
-
// FormInput -> Either String String
|
|
198
|
-
export const fieldIsRequired = ({ form, keyName }) =>
|
|
199
|
-
S.pipe([
|
|
200
|
-
getsMaybeString(keyName),
|
|
201
|
-
S.maybeToEither("Invalid string entered"),
|
|
202
|
-
S.chain(string =>
|
|
203
|
-
string.replace(/\s/g, "").length === 0
|
|
204
|
-
? S.Left(REQUIRED_FIELD_ERROR)
|
|
205
|
-
: S.Right(string)
|
|
206
|
-
)
|
|
207
|
-
])(form);
|
|
208
|
-
|
|
209
|
-
// Number -> FormInput -> Either String String
|
|
210
|
-
export const numberIsGreaterThan = minValue => ({ form, keyName }) =>
|
|
211
|
-
S.pipe([
|
|
212
|
-
getsMaybeString(keyName),
|
|
213
|
-
S.maybeToEither("Invalid string entered"),
|
|
214
|
-
S.chain(n =>
|
|
215
|
-
parseInt(n, 10) > minValue
|
|
216
|
-
? S.Right(n.toString())
|
|
217
|
-
: S.Left(NUM_GREATER_THAN_ERROR)
|
|
218
|
-
)
|
|
219
|
-
])(form);
|
|
220
|
-
|
|
221
|
-
// Number -> FormInput -> Either String String
|
|
222
|
-
export const numberIsLessThan = maxValue => ({ form, keyName }) =>
|
|
223
|
-
S.pipe([
|
|
224
|
-
getsMaybeString(keyName),
|
|
225
|
-
S.maybeToEither("Invalid string entered"),
|
|
226
|
-
S.chain(n =>
|
|
227
|
-
parseInt(n, 10) < maxValue
|
|
228
|
-
? S.Right(n.toString())
|
|
229
|
-
: S.Left(NUM_LESS_THAN_ERROR)
|
|
230
|
-
)
|
|
231
|
-
])(form);
|
|
232
|
-
|
|
233
|
-
// Error message splits the keyname on capital letters, joins with a space, and lower cases, so "accountNumber" becomes "account number"
|
|
234
|
-
// Eq a => FormInput -> String -> Either String a
|
|
235
|
-
export const matchesOtherField = matchKey => ({ form, keyName }) =>
|
|
236
|
-
S.equals(S.props([keyName, "value"])(form))(
|
|
237
|
-
S.props([matchKey, "value"])(form)
|
|
238
|
-
)
|
|
239
|
-
? S.Right(S.props([keyName, "value"])(form))
|
|
240
|
-
: S.Left(MATCHES_FIELD_ERROR);
|
|
241
|
-
|
|
242
|
-
// Array(String) -> FormInput -> Either String String
|
|
243
|
-
export const selectIsValid = validOptions => ({ form, keyName }) =>
|
|
244
|
-
S.pipe([
|
|
245
|
-
getsMaybeString(keyName),
|
|
246
|
-
S.maybeToEither("Invalid string entered"),
|
|
247
|
-
S.chain(string =>
|
|
248
|
-
R.contains(S.toUpper(string), validOptions)
|
|
249
|
-
? S.Right(string)
|
|
250
|
-
: S.Left(VALID_SELECT_OPTION_ERROR)
|
|
251
|
-
)
|
|
252
|
-
])(form);
|
|
253
|
-
|
|
254
|
-
export const isInputInvalid = input => input.error && input.showError;
|
|
255
|
-
|
|
256
|
-
export const inputErrorMessage = input =>
|
|
257
|
-
input.showError ? input.errorMsg : "";
|