@thecb/components 4.1.10-beta.1 → 4.1.11

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 CHANGED
@@ -34265,33 +34265,17 @@ 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");
34268
+ var stateProvinceErrorMessages = _defineProperty({}, required.error, "State or Province is required"); // const countryErrorMessages = {
34269
+ // [required.error]: "Country is required"
34270
+ // };
34269
34271
 
34270
- var countryErrorMessages = _defineProperty({}, required.error, "Country is required");
34271
34272
 
34272
34273
  var isUS = fields.country.rawValue === "US";
34273
34274
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
34274
34275
  variant: variant,
34275
34276
  role: "form",
34276
34277
  "aria-label": "Address"
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, {
34278
+ }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(FormInput$1, {
34295
34279
  labelTextWhenNoError: "Address",
34296
34280
  errorMessages: street1ErrorMessages,
34297
34281
  field: fields.street1,
@@ -38762,7 +38746,8 @@ var PaymentButtonBar = function PaymentButtonBar(_ref) {
38762
38746
  cancelText = _ref$cancelText === void 0 ? "Cancel" : _ref$cancelText,
38763
38747
  redirectURL = _ref.redirectURL,
38764
38748
  _ref$redirectText = _ref.redirectText,
38765
- redirectText = _ref$redirectText === void 0 ? "Return" : _ref$redirectText;
38749
+ redirectText = _ref$redirectText === void 0 ? "Return" : _ref$redirectText,
38750
+ buttonFlexOverride = _ref.buttonFlexOverride;
38766
38751
 
38767
38752
  var _useContext = React.useContext(styled.ThemeContext),
38768
38753
  isMobile = _useContext.isMobile;
@@ -38799,7 +38784,7 @@ var PaymentButtonBar = function PaymentButtonBar(_ref) {
38799
38784
  }), /*#__PURE__*/React__default.createElement(SolidDivider$1, null), /*#__PURE__*/React__default.createElement(Box, {
38800
38785
  padding: "2.5rem 0 3.125rem 0"
38801
38786
  }, /*#__PURE__*/React__default.createElement(Cluster, {
38802
- justify: !!backButton ? "space-between" : "flex-end",
38787
+ justify: buttonFlexOverride ? buttonFlexOverride : !!backButton ? "space-between" : "flex-end",
38803
38788
  align: "center",
38804
38789
  childGap: "0.75rem"
38805
38790
  }, backButton, forwardButton)));
@@ -39343,8 +39328,6 @@ var expirationDateErrors = (_expirationDateErrors = {}, _defineProperty(_expirat
39343
39328
  var cvvErrors = (_cvvErrors = {}, _defineProperty(_cvvErrors, required.error, "CVV is required"), _defineProperty(_cvvErrors, hasLength.error, "CVV is invalid"), _cvvErrors);
39344
39329
  var zipCodeErrors = (_zipCodeErrors = {}, _defineProperty(_zipCodeErrors, required.error, "Zip code is required"), _defineProperty(_zipCodeErrors, hasLength.error, "Zip code is invalid"), _zipCodeErrors);
39345
39330
 
39346
- var countryErrorMessages = _defineProperty({}, required.error, "Country is required");
39347
-
39348
39331
  var PaymentFormCard = function PaymentFormCard(_ref) {
39349
39332
  var _ref$variant = _ref.variant,
39350
39333
  variant = _ref$variant === void 0 ? "default" : _ref$variant,
@@ -39379,25 +39362,11 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
39379
39362
  };
39380
39363
  }
39381
39364
  }, []);
39382
- var isUS = fields.country.rawValue === "US";
39383
39365
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
39384
39366
  variant: variant,
39385
39367
  role: "form",
39386
39368
  "aria-label": "Card payment"
39387
- }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(CountryDropdown, {
39388
- labelTextWhenNoError: "Country",
39389
- errorMessages: countryErrorMessages,
39390
- field: fields.country,
39391
- onChange: function onChange(value) {
39392
- actions.fields.country.set(value); // temporary measure to not dirty fields until
39393
- // we can write a reset function for fields
39394
-
39395
- if (fields.zipCode.rawValue) {
39396
- actions.fields.zipCode.set("");
39397
- }
39398
- },
39399
- showErrors: showErrors
39400
- }), /*#__PURE__*/React__default.createElement(FormInput$1, {
39369
+ }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(FormInput$1, {
39401
39370
  labelTextWhenNoError: "Name on card",
39402
39371
  errorMessages: nameOnCardErrors,
39403
39372
  field: fields.nameOnCard,
@@ -39442,8 +39411,6 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
39442
39411
  padding: isMobile ? "0" : "0 0.5rem 0 0",
39443
39412
  width: isMobile ? "100%" : "50%"
39444
39413
  }, /*#__PURE__*/React__default.createElement(FormInput$1, {
39445
- isNum: isUS,
39446
- formatter: isUS ? zipFormat : null,
39447
39414
  labelTextWhenNoError: "Zip code",
39448
39415
  errorMessages: zipCodeErrors,
39449
39416
  field: fields.zipCode,
@@ -39473,10 +39440,6 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
39473
39440
  };
39474
39441
 
39475
39442
  var formConfig$7 = {
39476
- country: {
39477
- defaultValue: "US",
39478
- validators: [required()]
39479
- },
39480
39443
  nameOnCard: {
39481
39444
  validators: [required()]
39482
39445
  },
@@ -39493,8 +39456,8 @@ var formConfig$7 = {
39493
39456
  constraints: [onlyIntegers(), hasLength(0, 4)]
39494
39457
  },
39495
39458
  zipCode: {
39496
- validators: [required(), validateWhen(validateWhen(hasLength(5, 5), hasLength(0, 5)), matchesRegex("US"), "country"), validateWhen(validateWhen(hasLength(9, 9), hasLength(6, 9)), matchesRegex("US"), "country")],
39497
- constraints: [validateWhen(onlyIntegers(), matchesRegex("US"), "country"), validateWhen(hasLength(0, 9), matchesRegex("US"), "country")]
39459
+ validators: [required(), hasLength(5, 5)],
39460
+ constraints: [onlyIntegers(), hasLength(0, 5)]
39498
39461
  }
39499
39462
  };
39500
39463
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "4.1.10-beta.1",
3
+ "version": "4.1.11",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -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
- import CountryDropdown from "../../atoms/country-dropdown";
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
- const countryErrorMessages = {
55
- [required.error]: "Country is required"
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
- <CountryDropdown
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}
@@ -16,7 +16,8 @@ const PaymentButtonBar = ({
16
16
  cancelURL,
17
17
  cancelText = "Cancel",
18
18
  redirectURL,
19
- redirectText = "Return"
19
+ redirectText = "Return",
20
+ buttonFlexOverride
20
21
  }) => {
21
22
  const { isMobile } = useContext(ThemeContext);
22
23
 
@@ -68,7 +69,13 @@ const PaymentButtonBar = ({
68
69
  <SolidDivider />
69
70
  <Box padding="2.5rem 0 3.125rem 0">
70
71
  <Cluster
71
- justify={!!backButton ? "space-between" : "flex-end"}
72
+ justify={
73
+ buttonFlexOverride
74
+ ? buttonFlexOverride
75
+ : !!backButton
76
+ ? "space-between"
77
+ : "flex-end"
78
+ }
72
79
  align="center"
73
80
  childGap="0.75rem"
74
81
  >
@@ -2,13 +2,8 @@ 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";
6
5
  import { checkCardBrand, noop } from "../../../util/general";
7
- import {
8
- expirationDateFormat,
9
- creditCardFormat,
10
- zipFormat
11
- } from "../../../util/formats";
6
+ import { expirationDateFormat, creditCardFormat } from "../../../util/formats";
12
7
  import {
13
8
  FormInput,
14
9
  FormInputColumn,
@@ -41,9 +36,6 @@ const zipCodeErrors = {
41
36
  [required.error]: "Zip code is required",
42
37
  [hasLength.error]: "Zip code is invalid"
43
38
  };
44
- const countryErrorMessages = {
45
- [required.error]: "Country is required"
46
- };
47
39
 
48
40
  const PaymentFormCard = ({
49
41
  variant = "default",
@@ -69,24 +61,9 @@ const PaymentFormCard = ({
69
61
  return () => actions.form.clear();
70
62
  }
71
63
  }, []);
72
- const isUS = fields.country.rawValue === "US";
73
64
  return (
74
65
  <FormContainer variant={variant} role="form" aria-label="Card payment">
75
66
  <FormInputColumn>
76
- <CountryDropdown
77
- labelTextWhenNoError="Country"
78
- errorMessages={countryErrorMessages}
79
- field={fields.country}
80
- onChange={value => {
81
- actions.fields.country.set(value);
82
- // temporary measure to not dirty fields until
83
- // we can write a reset function for fields
84
- if (fields.zipCode.rawValue) {
85
- actions.fields.zipCode.set("");
86
- }
87
- }}
88
- showErrors={showErrors}
89
- />
90
67
  <FormInput
91
68
  labelTextWhenNoError="Name on card"
92
69
  errorMessages={nameOnCardErrors}
@@ -134,8 +111,6 @@ const PaymentFormCard = ({
134
111
  width={isMobile ? "100%" : "50%"}
135
112
  >
136
113
  <FormInput
137
- isNum={isUS}
138
- formatter={isUS ? zipFormat : null}
139
114
  labelTextWhenNoError="Zip code"
140
115
  errorMessages={zipCodeErrors}
141
116
  field={fields.zipCode}
@@ -3,17 +3,12 @@ import {
3
3
  required,
4
4
  onlyIntegers,
5
5
  hasLength,
6
- matchesRegex,
7
- validateWhen
6
+ matchesRegex
8
7
  } from "redux-freeform";
9
8
 
10
9
  //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.
11
10
 
12
11
  const formConfig = {
13
- country: {
14
- defaultValue: "US",
15
- validators: [required()]
16
- },
17
12
  nameOnCard: {
18
13
  validators: [required()]
19
14
  },
@@ -34,23 +29,8 @@ const formConfig = {
34
29
  constraints: [onlyIntegers(), hasLength(0, 4)]
35
30
  },
36
31
  zipCode: {
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
- ]
32
+ validators: [required(), hasLength(5, 5)],
33
+ constraints: [onlyIntegers(), hasLength(0, 5)]
54
34
  }
55
35
  };
56
36