@thecb/components 4.1.11 → 4.1.13
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 +50 -10
- package/package.json +1 -1
- package/src/components/molecules/address-form/AddressForm.js +6 -6
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.js +33 -31
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +28 -1
- package/src/components/molecules/payment-form-card/PaymentFormCard.state.js +23 -3
package/dist/index.cjs.js
CHANGED
|
@@ -34265,17 +34265,33 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
34265
34265
|
|
|
34266
34266
|
var zipErrorMessages = (_zipErrorMessages = {}, _defineProperty(_zipErrorMessages, required.error, "Zip code is required"), _defineProperty(_zipErrorMessages, hasLength.error, "Zip code must be 5 or 9 digits"), _zipErrorMessages);
|
|
34267
34267
|
|
|
34268
|
-
var stateProvinceErrorMessages = _defineProperty({}, required.error, "State or Province is required");
|
|
34269
|
-
// [required.error]: "Country is required"
|
|
34270
|
-
// };
|
|
34268
|
+
var stateProvinceErrorMessages = _defineProperty({}, required.error, "State or Province is required");
|
|
34271
34269
|
|
|
34270
|
+
var countryErrorMessages = _defineProperty({}, required.error, "Country is required");
|
|
34272
34271
|
|
|
34273
34272
|
var isUS = fields.country.rawValue === "US";
|
|
34274
34273
|
return /*#__PURE__*/React__default.createElement(FormContainer$1, {
|
|
34275
34274
|
variant: variant,
|
|
34276
34275
|
role: "form",
|
|
34277
34276
|
"aria-label": "Address"
|
|
34278
|
-
}, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(
|
|
34277
|
+
}, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(CountryDropdown, {
|
|
34278
|
+
labelTextWhenNoError: "Country",
|
|
34279
|
+
errorMessages: countryErrorMessages,
|
|
34280
|
+
field: fields.country,
|
|
34281
|
+
onChange: function onChange(value) {
|
|
34282
|
+
actions.fields.country.set(value); // temporary measure to not dirty fields until
|
|
34283
|
+
// we can write a reset function for fields
|
|
34284
|
+
|
|
34285
|
+
if (fields.stateProvince.rawValue) {
|
|
34286
|
+
actions.fields.stateProvince.set("");
|
|
34287
|
+
}
|
|
34288
|
+
|
|
34289
|
+
if (fields.zip.rawValue) {
|
|
34290
|
+
actions.fields.zip.set("");
|
|
34291
|
+
}
|
|
34292
|
+
},
|
|
34293
|
+
showErrors: showErrors
|
|
34294
|
+
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
34279
34295
|
labelTextWhenNoError: "Address",
|
|
34280
34296
|
errorMessages: street1ErrorMessages,
|
|
34281
34297
|
field: fields.street1,
|
|
@@ -35124,10 +35140,12 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
|
|
|
35124
35140
|
boxShadow: "0px 0px 4px 0px rgb(110, 114, 126)",
|
|
35125
35141
|
role: "region",
|
|
35126
35142
|
"aria-label": "Payment step"
|
|
35143
|
+
}, /*#__PURE__*/React__default.createElement(Center, {
|
|
35144
|
+
maxWidth: "76.5rem"
|
|
35127
35145
|
}, /*#__PURE__*/React__default.createElement(Reel, {
|
|
35128
35146
|
padding: "0",
|
|
35129
|
-
childGap: "
|
|
35130
|
-
childWidth: "
|
|
35147
|
+
childGap: "4.5rem",
|
|
35148
|
+
childWidth: "11rem",
|
|
35131
35149
|
justifyContent: "space-evenly",
|
|
35132
35150
|
disableScroll: true
|
|
35133
35151
|
}, repeat( /*#__PURE__*/React__default.createElement(Box, null), boxesBefore), tabs.map(function (t, i) {
|
|
@@ -35144,7 +35162,7 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
|
|
|
35144
35162
|
weight: FONT_WEIGHT_SEMIBOLD,
|
|
35145
35163
|
extraStyles: "display: block; white-space: nowrap;"
|
|
35146
35164
|
}, t));
|
|
35147
|
-
}), repeat( /*#__PURE__*/React__default.createElement(Box, null), boxesAfter)));
|
|
35165
|
+
}), repeat( /*#__PURE__*/React__default.createElement(Box, null), boxesAfter))));
|
|
35148
35166
|
};
|
|
35149
35167
|
|
|
35150
35168
|
var HighlightTabRow$1 = /*#__PURE__*/React.memo(themeComponent(HighlightTabRow, "HighlightTabRow", fallbackValues$s));
|
|
@@ -39328,6 +39346,8 @@ var expirationDateErrors = (_expirationDateErrors = {}, _defineProperty(_expirat
|
|
|
39328
39346
|
var cvvErrors = (_cvvErrors = {}, _defineProperty(_cvvErrors, required.error, "CVV is required"), _defineProperty(_cvvErrors, hasLength.error, "CVV is invalid"), _cvvErrors);
|
|
39329
39347
|
var zipCodeErrors = (_zipCodeErrors = {}, _defineProperty(_zipCodeErrors, required.error, "Zip code is required"), _defineProperty(_zipCodeErrors, hasLength.error, "Zip code is invalid"), _zipCodeErrors);
|
|
39330
39348
|
|
|
39349
|
+
var countryErrorMessages = _defineProperty({}, required.error, "Country is required");
|
|
39350
|
+
|
|
39331
39351
|
var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
39332
39352
|
var _ref$variant = _ref.variant,
|
|
39333
39353
|
variant = _ref$variant === void 0 ? "default" : _ref$variant,
|
|
@@ -39362,11 +39382,25 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
39362
39382
|
};
|
|
39363
39383
|
}
|
|
39364
39384
|
}, []);
|
|
39385
|
+
var isUS = fields.country.rawValue === "US";
|
|
39365
39386
|
return /*#__PURE__*/React__default.createElement(FormContainer$1, {
|
|
39366
39387
|
variant: variant,
|
|
39367
39388
|
role: "form",
|
|
39368
39389
|
"aria-label": "Card payment"
|
|
39369
|
-
}, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(
|
|
39390
|
+
}, /*#__PURE__*/React__default.createElement(FormInputColumn, null, !hideZipCode && /*#__PURE__*/React__default.createElement(CountryDropdown, {
|
|
39391
|
+
labelTextWhenNoError: "Country",
|
|
39392
|
+
errorMessages: countryErrorMessages,
|
|
39393
|
+
field: fields.country,
|
|
39394
|
+
onChange: function onChange(value) {
|
|
39395
|
+
actions.fields.country.set(value); // temporary measure to not dirty fields until
|
|
39396
|
+
// we can write a reset function for fields
|
|
39397
|
+
|
|
39398
|
+
if (fields.zipCode.rawValue) {
|
|
39399
|
+
actions.fields.zipCode.set("");
|
|
39400
|
+
}
|
|
39401
|
+
},
|
|
39402
|
+
showErrors: showErrors
|
|
39403
|
+
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
39370
39404
|
labelTextWhenNoError: "Name on card",
|
|
39371
39405
|
errorMessages: nameOnCardErrors,
|
|
39372
39406
|
field: fields.nameOnCard,
|
|
@@ -39411,6 +39445,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
39411
39445
|
padding: isMobile ? "0" : "0 0.5rem 0 0",
|
|
39412
39446
|
width: isMobile ? "100%" : "50%"
|
|
39413
39447
|
}, /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
39448
|
+
isNum: isUS,
|
|
39449
|
+
formatter: isUS ? zipFormat : null,
|
|
39414
39450
|
labelTextWhenNoError: "Zip code",
|
|
39415
39451
|
errorMessages: zipCodeErrors,
|
|
39416
39452
|
field: fields.zipCode,
|
|
@@ -39440,6 +39476,10 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
39440
39476
|
};
|
|
39441
39477
|
|
|
39442
39478
|
var formConfig$7 = {
|
|
39479
|
+
country: {
|
|
39480
|
+
defaultValue: "US",
|
|
39481
|
+
validators: [required()]
|
|
39482
|
+
},
|
|
39443
39483
|
nameOnCard: {
|
|
39444
39484
|
validators: [required()]
|
|
39445
39485
|
},
|
|
@@ -39456,8 +39496,8 @@ var formConfig$7 = {
|
|
|
39456
39496
|
constraints: [onlyIntegers(), hasLength(0, 4)]
|
|
39457
39497
|
},
|
|
39458
39498
|
zipCode: {
|
|
39459
|
-
validators: [required(), hasLength(5, 5)],
|
|
39460
|
-
constraints: [onlyIntegers(), hasLength(0,
|
|
39499
|
+
validators: [required(), validateWhen(validateWhen(hasLength(5, 5), hasLength(0, 5)), matchesRegex("US"), "country"), validateWhen(validateWhen(hasLength(9, 9), hasLength(6, 9)), matchesRegex("US"), "country")],
|
|
39500
|
+
constraints: [validateWhen(onlyIntegers(), matchesRegex("US"), "country"), validateWhen(hasLength(0, 9), matchesRegex("US"), "country")]
|
|
39461
39501
|
}
|
|
39462
39502
|
};
|
|
39463
39503
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { required, hasLength } from "redux-freeform";
|
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
import StateProvinceDropdown from "../../atoms/state-province-dropdown";
|
|
5
5
|
import Checkbox from "../../atoms/checkbox";
|
|
6
|
-
|
|
6
|
+
import CountryDropdown from "../../atoms/country-dropdown";
|
|
7
7
|
import { zipFormat } from "../../../util/formats";
|
|
8
8
|
import { noop } from "../../../util/general";
|
|
9
9
|
import {
|
|
@@ -51,16 +51,16 @@ const AddressForm = ({
|
|
|
51
51
|
const stateProvinceErrorMessages = {
|
|
52
52
|
[required.error]: "State or Province is required"
|
|
53
53
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const countryErrorMessages = {
|
|
55
|
+
[required.error]: "Country is required"
|
|
56
|
+
};
|
|
57
57
|
|
|
58
58
|
const isUS = fields.country.rawValue === "US";
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<FormContainer variant={variant} role="form" aria-label="Address">
|
|
62
62
|
<FormInputColumn>
|
|
63
|
-
|
|
63
|
+
<CountryDropdown
|
|
64
64
|
labelTextWhenNoError="Country"
|
|
65
65
|
errorMessages={countryErrorMessages}
|
|
66
66
|
field={fields.country}
|
|
@@ -76,7 +76,7 @@ const AddressForm = ({
|
|
|
76
76
|
}
|
|
77
77
|
}}
|
|
78
78
|
showErrors={showErrors}
|
|
79
|
-
/>
|
|
79
|
+
/>
|
|
80
80
|
<FormInput
|
|
81
81
|
labelTextWhenNoError="Address"
|
|
82
82
|
errorMessages={street1ErrorMessages}
|
|
@@ -3,7 +3,7 @@ import { repeat } from "ramda";
|
|
|
3
3
|
|
|
4
4
|
import { fallbackValues } from "./HighlightTabRow.theme";
|
|
5
5
|
import { themeComponent } from "../../../util/themeUtils";
|
|
6
|
-
import { Reel, Box } from "../../atoms/layouts";
|
|
6
|
+
import { Reel, Box, Center } from "../../atoms/layouts";
|
|
7
7
|
import Text from "../../atoms/text";
|
|
8
8
|
import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
|
|
9
9
|
|
|
@@ -28,37 +28,39 @@ const HighlightTabRow = ({ tabs, highlightIndex, themeValues, isMobile }) => {
|
|
|
28
28
|
role="region"
|
|
29
29
|
aria-label="Payment step"
|
|
30
30
|
>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<Text
|
|
50
|
-
variant="p"
|
|
51
|
-
textAlign="center"
|
|
52
|
-
color={themeValues.textColor}
|
|
53
|
-
weight={FONT_WEIGHT_SEMIBOLD}
|
|
54
|
-
extraStyles="display: block; white-space: nowrap;"
|
|
31
|
+
<Center maxWidth="76.5rem">
|
|
32
|
+
<Reel
|
|
33
|
+
padding="0"
|
|
34
|
+
childGap="4.5rem"
|
|
35
|
+
childWidth="11rem"
|
|
36
|
+
justifyContent="space-evenly"
|
|
37
|
+
disableScroll
|
|
38
|
+
>
|
|
39
|
+
{repeat(<Box />, boxesBefore)}
|
|
40
|
+
{tabs.map((t, i) => (
|
|
41
|
+
<Box
|
|
42
|
+
key={t}
|
|
43
|
+
borderSize="3px"
|
|
44
|
+
borderColor={
|
|
45
|
+
highlightIndex == i ? themeValues.textColor : "transparent"
|
|
46
|
+
}
|
|
47
|
+
borderWidthOverride="0 0 3px 0"
|
|
48
|
+
extraStyles="text-align: center;"
|
|
55
49
|
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
<Text
|
|
51
|
+
variant="p"
|
|
52
|
+
textAlign="center"
|
|
53
|
+
color={themeValues.textColor}
|
|
54
|
+
weight={FONT_WEIGHT_SEMIBOLD}
|
|
55
|
+
extraStyles="display: block; white-space: nowrap;"
|
|
56
|
+
>
|
|
57
|
+
{t}
|
|
58
|
+
</Text>
|
|
59
|
+
</Box>
|
|
60
|
+
))}
|
|
61
|
+
{repeat(<Box />, boxesAfter)}
|
|
62
|
+
</Reel>
|
|
63
|
+
</Center>
|
|
62
64
|
</Box>
|
|
63
65
|
);
|
|
64
66
|
};
|
|
@@ -2,8 +2,13 @@ import React, { useEffect, useState } from "react";
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import { required, hasLength, matchesRegex } from "redux-freeform";
|
|
4
4
|
import Checkbox from "../../atoms/checkbox";
|
|
5
|
+
import CountryDropdown from "../../atoms/country-dropdown";
|
|
5
6
|
import { checkCardBrand, noop } from "../../../util/general";
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
expirationDateFormat,
|
|
9
|
+
creditCardFormat,
|
|
10
|
+
zipFormat
|
|
11
|
+
} from "../../../util/formats";
|
|
7
12
|
import {
|
|
8
13
|
FormInput,
|
|
9
14
|
FormInputColumn,
|
|
@@ -36,6 +41,9 @@ const zipCodeErrors = {
|
|
|
36
41
|
[required.error]: "Zip code is required",
|
|
37
42
|
[hasLength.error]: "Zip code is invalid"
|
|
38
43
|
};
|
|
44
|
+
const countryErrorMessages = {
|
|
45
|
+
[required.error]: "Country is required"
|
|
46
|
+
};
|
|
39
47
|
|
|
40
48
|
const PaymentFormCard = ({
|
|
41
49
|
variant = "default",
|
|
@@ -61,9 +69,26 @@ const PaymentFormCard = ({
|
|
|
61
69
|
return () => actions.form.clear();
|
|
62
70
|
}
|
|
63
71
|
}, []);
|
|
72
|
+
const isUS = fields.country.rawValue === "US";
|
|
64
73
|
return (
|
|
65
74
|
<FormContainer variant={variant} role="form" aria-label="Card payment">
|
|
66
75
|
<FormInputColumn>
|
|
76
|
+
{!hideZipCode && (
|
|
77
|
+
<CountryDropdown
|
|
78
|
+
labelTextWhenNoError="Country"
|
|
79
|
+
errorMessages={countryErrorMessages}
|
|
80
|
+
field={fields.country}
|
|
81
|
+
onChange={value => {
|
|
82
|
+
actions.fields.country.set(value);
|
|
83
|
+
// temporary measure to not dirty fields until
|
|
84
|
+
// we can write a reset function for fields
|
|
85
|
+
if (fields.zipCode.rawValue) {
|
|
86
|
+
actions.fields.zipCode.set("");
|
|
87
|
+
}
|
|
88
|
+
}}
|
|
89
|
+
showErrors={showErrors}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
67
92
|
<FormInput
|
|
68
93
|
labelTextWhenNoError="Name on card"
|
|
69
94
|
errorMessages={nameOnCardErrors}
|
|
@@ -111,6 +136,8 @@ const PaymentFormCard = ({
|
|
|
111
136
|
width={isMobile ? "100%" : "50%"}
|
|
112
137
|
>
|
|
113
138
|
<FormInput
|
|
139
|
+
isNum={isUS}
|
|
140
|
+
formatter={isUS ? zipFormat : null}
|
|
114
141
|
labelTextWhenNoError="Zip code"
|
|
115
142
|
errorMessages={zipCodeErrors}
|
|
116
143
|
field={fields.zipCode}
|
|
@@ -3,12 +3,17 @@ import {
|
|
|
3
3
|
required,
|
|
4
4
|
onlyIntegers,
|
|
5
5
|
hasLength,
|
|
6
|
-
matchesRegex
|
|
6
|
+
matchesRegex,
|
|
7
|
+
validateWhen
|
|
7
8
|
} from "redux-freeform";
|
|
8
9
|
|
|
9
10
|
//TODO: Will make zip code able to have more than 5 digits once we add in the FormattedInput because it will have issues with format of 60606-1111.
|
|
10
11
|
|
|
11
12
|
const formConfig = {
|
|
13
|
+
country: {
|
|
14
|
+
defaultValue: "US",
|
|
15
|
+
validators: [required()]
|
|
16
|
+
},
|
|
12
17
|
nameOnCard: {
|
|
13
18
|
validators: [required()]
|
|
14
19
|
},
|
|
@@ -29,8 +34,23 @@ const formConfig = {
|
|
|
29
34
|
constraints: [onlyIntegers(), hasLength(0, 4)]
|
|
30
35
|
},
|
|
31
36
|
zipCode: {
|
|
32
|
-
validators: [
|
|
33
|
-
|
|
37
|
+
validators: [
|
|
38
|
+
required(),
|
|
39
|
+
validateWhen(
|
|
40
|
+
validateWhen(hasLength(5, 5), hasLength(0, 5)),
|
|
41
|
+
matchesRegex("US"),
|
|
42
|
+
"country"
|
|
43
|
+
),
|
|
44
|
+
validateWhen(
|
|
45
|
+
validateWhen(hasLength(9, 9), hasLength(6, 9)),
|
|
46
|
+
matchesRegex("US"),
|
|
47
|
+
"country"
|
|
48
|
+
)
|
|
49
|
+
],
|
|
50
|
+
constraints: [
|
|
51
|
+
validateWhen(onlyIntegers(), matchesRegex("US"), "country"),
|
|
52
|
+
validateWhen(hasLength(0, 9), matchesRegex("US"), "country")
|
|
53
|
+
]
|
|
34
54
|
}
|
|
35
55
|
};
|
|
36
56
|
|