@thecb/components 4.1.8 → 4.1.10-beta.1

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
@@ -14720,6 +14720,47 @@ var StatusUnknownIcon = function StatusUnknownIcon() {
14720
14720
  }))));
14721
14721
  };
14722
14722
 
14723
+ var CarrotIcon = function CarrotIcon(_ref) {
14724
+ var themeValues = _ref.themeValues;
14725
+ return /*#__PURE__*/React__default.createElement("svg", {
14726
+ xmlns: "http://www.w3.org/2000/svg",
14727
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
14728
+ width: "10",
14729
+ height: "5",
14730
+ viewBox: "0 0 10 5"
14731
+ }, /*#__PURE__*/React__default.createElement("defs", null, /*#__PURE__*/React__default.createElement("path", {
14732
+ id: "carrot-path-1",
14733
+ d: "M6.99999958 9.9999994L11.9999993 14.9999991 16.999999 9.9999994z"
14734
+ })), /*#__PURE__*/React__default.createElement("g", {
14735
+ fill: "none",
14736
+ fillRule: "evenodd",
14737
+ stroke: "none",
14738
+ strokeWidth: "1"
14739
+ }, /*#__PURE__*/React__default.createElement("g", {
14740
+ transform: "translate(-423 -974)"
14741
+ }, /*#__PURE__*/React__default.createElement("g", {
14742
+ transform: "translate(372 958)"
14743
+ }, /*#__PURE__*/React__default.createElement("g", {
14744
+ transform: "translate(44 6)"
14745
+ }, /*#__PURE__*/React__default.createElement("mask", {
14746
+ id: "carrot-mask-2",
14747
+ fill: "#fff"
14748
+ }, /*#__PURE__*/React__default.createElement("use", {
14749
+ xlinkHref: "#carrot-path-1"
14750
+ })), /*#__PURE__*/React__default.createElement("use", {
14751
+ fill: "#000",
14752
+ xlinkHref: "#carrot-path-1"
14753
+ }), /*#__PURE__*/React__default.createElement("g", {
14754
+ fill: themeValues.singleIconColor,
14755
+ fillRule: "nonzero",
14756
+ mask: "url(#carrot-mask-2)"
14757
+ }, /*#__PURE__*/React__default.createElement("g", null, /*#__PURE__*/React__default.createElement("path", {
14758
+ d: "M0 0H24V24H0z"
14759
+ }))))))));
14760
+ };
14761
+
14762
+ var CarrotIcon$1 = themeComponent(CarrotIcon, "Icons", fallbackValues$2, "darkMode");
14763
+
14723
14764
  var color$2 = "#15749D";
14724
14765
  var hoverColor$1 = "#116285";
14725
14766
  var activeColor$1 = "#0E506D";
@@ -18866,7 +18907,7 @@ function _templateObject3$5() {
18866
18907
  }
18867
18908
 
18868
18909
  function _templateObject2$b() {
18869
- var data = _taggedTemplateLiteral(["\n transform-origin: 0 0;\n border: 1px solid ", ";\n border-radius: 2px;\n background-color: ", ";\n padding: 8px 0 8px;\n position: absolute;\n width: 100%;\n max-height: ", ";\n overflow-y: scroll;\n z-index: 1;\n box-sizing: border-box;\n &:focus {\n outline: none;\n }\n"]);
18910
+ var data = _taggedTemplateLiteral(["\n transform-origin: 0 0;\n border: 1px solid ", ";\n border-radius: 2px;\n background-color: ", ";\n padding: 8px 0 8px;\n position: absolute;\n width: ", ";\n min-width: 100%;\n max-height: ", ";\n overflow-y: scroll;\n z-index: 1;\n box-sizing: border-box;\n &:focus {\n outline: none;\n }\n"]);
18870
18911
 
18871
18912
  _templateObject2$b = function _templateObject2() {
18872
18913
  return data;
@@ -18876,7 +18917,7 @@ function _templateObject2$b() {
18876
18917
  }
18877
18918
 
18878
18919
  function _templateObject$n() {
18879
- var data = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n transition: transform 0.3s ease;\n ", "\n"]);
18920
+ var data = _taggedTemplateLiteral(["\n display: flex;\n padding-left: 8px;\n flex-direction: column;\n justify-content: center;\n transition: transform 0.3s ease;\n ", "\n"]);
18880
18921
 
18881
18922
  _templateObject$n = function _templateObject() {
18882
18923
  return data;
@@ -18889,47 +18930,52 @@ var IconWrapper = styled__default.div(_templateObject$n(), function (_ref) {
18889
18930
  return open ? "transform: rotate(-180deg)" : "";
18890
18931
  });
18891
18932
  var DropdownContentWrapper = styled__default.div(_templateObject2$b(), GREY_CHATEAU, WHITE, function (_ref2) {
18892
- var maxHeight = _ref2.maxHeight;
18933
+ var widthFitOptions = _ref2.widthFitOptions;
18934
+ return widthFitOptions ? "fit-content" : "100%";
18935
+ }, function (_ref3) {
18936
+ var maxHeight = _ref3.maxHeight;
18893
18937
  return maxHeight || "400px";
18894
18938
  });
18895
- var DropdownItemWrapper = styled__default.div(_templateObject3$5(), function (_ref3) {
18896
- var selected = _ref3.selected,
18897
- themeValues = _ref3.themeValues;
18939
+ var DropdownItemWrapper = styled__default.div(_templateObject3$5(), function (_ref4) {
18940
+ var selected = _ref4.selected,
18941
+ themeValues = _ref4.themeValues;
18898
18942
  return selected ? themeValues.selectedColor : WHITE;
18899
- }, function (_ref4) {
18900
- var disabled = _ref4.disabled;
18901
- return disabled ? "default" : "pointer";
18902
18943
  }, function (_ref5) {
18903
- var selected = _ref5.selected,
18904
- disabled = _ref5.disabled,
18905
- themeValues = _ref5.themeValues;
18906
- return selected ? themeValues.selectedColor : disabled ? WHITE : themeValues.hoverColor;
18944
+ var disabled = _ref5.disabled;
18945
+ return disabled ? "default" : "pointer";
18907
18946
  }, function (_ref6) {
18908
18947
  var selected = _ref6.selected,
18909
18948
  disabled = _ref6.disabled,
18910
18949
  themeValues = _ref6.themeValues;
18911
18950
  return selected ? themeValues.selectedColor : disabled ? WHITE : themeValues.hoverColor;
18951
+ }, function (_ref7) {
18952
+ var selected = _ref7.selected,
18953
+ disabled = _ref7.disabled,
18954
+ themeValues = _ref7.themeValues;
18955
+ return selected ? themeValues.selectedColor : disabled ? WHITE : themeValues.hoverColor;
18912
18956
  });
18913
- var SearchInput = styled__default.input(_templateObject4$2(), function (_ref7) {
18914
- var themeValues = _ref7.themeValues;
18957
+ var SearchInput = styled__default.input(_templateObject4$2(), function (_ref8) {
18958
+ var themeValues = _ref8.themeValues;
18915
18959
  return themeValues.hoverColor && themeValues.hoverColor;
18916
18960
  });
18917
18961
 
18918
- var Dropdown = function Dropdown(_ref8) {
18962
+ var Dropdown = function Dropdown(_ref9) {
18919
18963
  var _options$find;
18920
18964
 
18921
- var placeholder = _ref8.placeholder,
18922
- options = _ref8.options,
18923
- value = _ref8.value,
18924
- isOpen = _ref8.isOpen,
18925
- isError = _ref8.isError,
18926
- onSelect = _ref8.onSelect,
18927
- _ref8$disabledValues = _ref8.disabledValues,
18928
- disabledValues = _ref8$disabledValues === void 0 ? [] : _ref8$disabledValues,
18929
- _ref8$onClick = _ref8.onClick,
18930
- onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
18931
- themeValues = _ref8.themeValues,
18932
- maxHeight = _ref8.maxHeight;
18965
+ var placeholder = _ref9.placeholder,
18966
+ options = _ref9.options,
18967
+ value = _ref9.value,
18968
+ isOpen = _ref9.isOpen,
18969
+ isError = _ref9.isError,
18970
+ onSelect = _ref9.onSelect,
18971
+ _ref9$disabledValues = _ref9.disabledValues,
18972
+ disabledValues = _ref9$disabledValues === void 0 ? [] : _ref9$disabledValues,
18973
+ _ref9$onClick = _ref9.onClick,
18974
+ onClick = _ref9$onClick === void 0 ? noop : _ref9$onClick,
18975
+ themeValues = _ref9.themeValues,
18976
+ maxHeight = _ref9.maxHeight,
18977
+ _ref9$widthFitOptions = _ref9.widthFitOptions,
18978
+ widthFitOptions = _ref9$widthFitOptions === void 0 ? false : _ref9$widthFitOptions;
18933
18979
 
18934
18980
  var _useState = React.useState(""),
18935
18981
  _useState2 = _slicedToArray(_useState, 2),
@@ -19025,7 +19071,7 @@ var Dropdown = function Dropdown(_ref8) {
19025
19071
  break;
19026
19072
  }
19027
19073
 
19028
- if (keyCode > 64 && keyCode < 91 || keyCode == 32) {
19074
+ if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
19029
19075
  e.preventDefault();
19030
19076
  setInputValue(inputValue + key);
19031
19077
  }
@@ -19096,6 +19142,7 @@ var Dropdown = function Dropdown(_ref8) {
19096
19142
  maxHeight: maxHeight,
19097
19143
  open: isOpen,
19098
19144
  ref: dropdownRef,
19145
+ widthFitOptions: widthFitOptions,
19099
19146
  tabIndex: 0
19100
19147
  }, /*#__PURE__*/React__default.createElement(Stack, {
19101
19148
  childGap: "0"
@@ -34218,17 +34265,33 @@ var AddressForm = function AddressForm(_ref) {
34218
34265
 
34219
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);
34220
34267
 
34221
- var stateProvinceErrorMessages = _defineProperty({}, required.error, "State or Province is required"); // const countryErrorMessages = {
34222
- // [required.error]: "Country is required"
34223
- // };
34268
+ var stateProvinceErrorMessages = _defineProperty({}, required.error, "State or Province is required");
34224
34269
 
34270
+ var countryErrorMessages = _defineProperty({}, required.error, "Country is required");
34225
34271
 
34226
34272
  var isUS = fields.country.rawValue === "US";
34227
34273
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
34228
34274
  variant: variant,
34229
34275
  role: "form",
34230
34276
  "aria-label": "Address"
34231
- }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(FormInput$1, {
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, {
34232
34295
  labelTextWhenNoError: "Address",
34233
34296
  errorMessages: street1ErrorMessages,
34234
34297
  field: fields.street1,
@@ -36534,9 +36597,9 @@ var fallbackValues$u = {
36534
36597
  var NavMenuDesktop = function NavMenuDesktop(_ref) {
36535
36598
  var id = _ref.id,
36536
36599
  _ref$top = _ref.top,
36537
- top = _ref$top === void 0 ? "125%" : _ref$top,
36600
+ top = _ref$top === void 0 ? "115%" : _ref$top,
36538
36601
  _ref$left = _ref.left,
36539
- left = _ref$left === void 0 ? "-100%" : _ref$left,
36602
+ left = _ref$left === void 0 ? "-165%" : _ref$left,
36540
36603
  _ref$menuContent = _ref.menuContent,
36541
36604
  menuContent = _ref$menuContent === void 0 ? [] : _ref$menuContent,
36542
36605
  _ref$visible = _ref.visible,
@@ -36559,7 +36622,7 @@ var NavMenuDesktop = function NavMenuDesktop(_ref) {
36559
36622
  extraStyles: "position: relative; ".concat(menuCarat),
36560
36623
  background: themeValues.backgroundColor,
36561
36624
  borderRadius: "5px",
36562
- boxShadow: "0px 3px 8px 0px ".concat(themeValues.shadowColor, ", 0px 2px 14px 0px ").concat(themeValues.shadowColor, ";"),
36625
+ boxShadow: "0px 1px 8px -1px rgba(0, 0, 0, 0.3), 0px 1px 4px 0px ".concat(themeValues.shadowColor, ", 0px 7px 32px 0px ").concat(themeValues.shadowColor),
36563
36626
  onMouseEnter: onMouseEnter,
36564
36627
  onMouseLeave: onMouseLeave,
36565
36628
  onFocus: onFocus,
@@ -39280,6 +39343,8 @@ var expirationDateErrors = (_expirationDateErrors = {}, _defineProperty(_expirat
39280
39343
  var cvvErrors = (_cvvErrors = {}, _defineProperty(_cvvErrors, required.error, "CVV is required"), _defineProperty(_cvvErrors, hasLength.error, "CVV is invalid"), _cvvErrors);
39281
39344
  var zipCodeErrors = (_zipCodeErrors = {}, _defineProperty(_zipCodeErrors, required.error, "Zip code is required"), _defineProperty(_zipCodeErrors, hasLength.error, "Zip code is invalid"), _zipCodeErrors);
39282
39345
 
39346
+ var countryErrorMessages = _defineProperty({}, required.error, "Country is required");
39347
+
39283
39348
  var PaymentFormCard = function PaymentFormCard(_ref) {
39284
39349
  var _ref$variant = _ref.variant,
39285
39350
  variant = _ref$variant === void 0 ? "default" : _ref$variant,
@@ -39314,11 +39379,25 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
39314
39379
  };
39315
39380
  }
39316
39381
  }, []);
39382
+ var isUS = fields.country.rawValue === "US";
39317
39383
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
39318
39384
  variant: variant,
39319
39385
  role: "form",
39320
39386
  "aria-label": "Card payment"
39321
- }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(FormInput$1, {
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, {
39322
39401
  labelTextWhenNoError: "Name on card",
39323
39402
  errorMessages: nameOnCardErrors,
39324
39403
  field: fields.nameOnCard,
@@ -39363,6 +39442,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
39363
39442
  padding: isMobile ? "0" : "0 0.5rem 0 0",
39364
39443
  width: isMobile ? "100%" : "50%"
39365
39444
  }, /*#__PURE__*/React__default.createElement(FormInput$1, {
39445
+ isNum: isUS,
39446
+ formatter: isUS ? zipFormat : null,
39366
39447
  labelTextWhenNoError: "Zip code",
39367
39448
  errorMessages: zipCodeErrors,
39368
39449
  field: fields.zipCode,
@@ -39392,6 +39473,10 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
39392
39473
  };
39393
39474
 
39394
39475
  var formConfig$7 = {
39476
+ country: {
39477
+ defaultValue: "US",
39478
+ validators: [required()]
39479
+ },
39395
39480
  nameOnCard: {
39396
39481
  validators: [required()]
39397
39482
  },
@@ -39408,8 +39493,8 @@ var formConfig$7 = {
39408
39493
  constraints: [onlyIntegers(), hasLength(0, 4)]
39409
39494
  },
39410
39495
  zipCode: {
39411
- validators: [required(), hasLength(5, 5)],
39412
- constraints: [onlyIntegers(), hasLength(0, 5)]
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")]
39413
39498
  }
39414
39499
  };
39415
39500
 
@@ -40674,6 +40759,7 @@ exports.Breadcrumb = Breadcrumbs;
40674
40759
  exports.ButtonWithAction = ButtonWithAction;
40675
40760
  exports.ButtonWithLink = ButtonWithLink;
40676
40761
  exports.CalendarIcon = CalendarIcon;
40762
+ exports.CarrotIcon = CarrotIcon$1;
40677
40763
  exports.Center = Center;
40678
40764
  exports.CenterSingle = CenterSingle$1;
40679
40765
  exports.CenterStack = CenterStack$1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "4.1.8",
3
+ "version": "4.1.10-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -17,6 +17,7 @@ import { themeComponent } from "../../../util/themeUtils";
17
17
 
18
18
  const IconWrapper = styled.div`
19
19
  display: flex;
20
+ padding-left: 8px;
20
21
  flex-direction: column;
21
22
  justify-content: center;
22
23
  transition: transform 0.3s ease;
@@ -30,7 +31,8 @@ const DropdownContentWrapper = styled.div`
30
31
  background-color: ${WHITE};
31
32
  padding: 8px 0 8px;
32
33
  position: absolute;
33
- width: 100%;
34
+ width: ${({ widthFitOptions }) => (widthFitOptions ? "fit-content" : "100%")};
35
+ min-width: 100%;
34
36
  max-height: ${({ maxHeight }) => maxHeight || "400px"};
35
37
  overflow-y: scroll;
36
38
  z-index: 1;
@@ -89,7 +91,8 @@ const Dropdown = ({
89
91
  disabledValues = [],
90
92
  onClick = noop,
91
93
  themeValues,
92
- maxHeight
94
+ maxHeight,
95
+ widthFitOptions = false
93
96
  }) => {
94
97
  const [inputValue, setInputValue] = useState("");
95
98
  const [optionsState, setOptionsState] = useState([]);
@@ -151,7 +154,7 @@ const Dropdown = ({
151
154
  setInputValue(inputValue.slice(0, -1));
152
155
  break;
153
156
  }
154
- if ((keyCode > 64 && keyCode < 91) || keyCode == 32) {
157
+ if ((keyCode > 64 && keyCode < 91) || keyCode == 32 || keyCode == 189) {
155
158
  e.preventDefault();
156
159
  setInputValue(inputValue + key);
157
160
  }
@@ -247,6 +250,7 @@ const Dropdown = ({
247
250
  maxHeight={maxHeight}
248
251
  open={isOpen}
249
252
  ref={dropdownRef}
253
+ widthFitOptions={widthFitOptions}
250
254
  tabIndex={0}
251
255
  >
252
256
  <Stack childGap="0">
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import { fallbackValues } from "./Icons.theme";
3
+ import { themeComponent } from "../../../util/themeUtils";
4
+
5
+ const CarrotIcon = ({ themeValues }) => {
6
+ return (
7
+ <svg
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ xmlnsXlink="http://www.w3.org/1999/xlink"
10
+ width="10"
11
+ height="5"
12
+ viewBox="0 0 10 5"
13
+ >
14
+ <defs>
15
+ <path
16
+ id="carrot-path-1"
17
+ d="M6.99999958 9.9999994L11.9999993 14.9999991 16.999999 9.9999994z"
18
+ ></path>
19
+ </defs>
20
+ <g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
21
+ <g transform="translate(-423 -974)">
22
+ <g transform="translate(372 958)">
23
+ <g transform="translate(44 6)">
24
+ <mask id="carrot-mask-2" fill="#fff">
25
+ <use xlinkHref="#carrot-path-1"></use>
26
+ </mask>
27
+ <use fill="#000" xlinkHref="#carrot-path-1"></use>
28
+ <g
29
+ fill={themeValues.singleIconColor}
30
+ fillRule="nonzero"
31
+ mask="url(#carrot-mask-2)"
32
+ >
33
+ <g>
34
+ <path d="M0 0H24V24H0z"></path>
35
+ </g>
36
+ </g>
37
+ </g>
38
+ </g>
39
+ </g>
40
+ </g>
41
+ </svg>
42
+ );
43
+ };
44
+
45
+ export default themeComponent(CarrotIcon, "Icons", fallbackValues, "darkMode");
@@ -39,6 +39,7 @@ import RejectedVelocityIcon from "./RejectedVelocityIcon";
39
39
  import SuccessfulIcon from "./SuccessfulIcon";
40
40
  import VoidedIcon from "./VoidedIcon";
41
41
  import StatusUnknownIcon from "./StatusUnknownIcon";
42
+ import CarrotIcon from "./CarrotIcon";
42
43
 
43
44
  export {
44
45
  AccountsIcon,
@@ -81,5 +82,6 @@ export {
81
82
  RejectedVelocityIcon,
82
83
  SuccessfulIcon,
83
84
  VoidedIcon,
84
- StatusUnknownIcon
85
+ StatusUnknownIcon,
86
+ CarrotIcon
85
87
  };
@@ -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}
@@ -5,8 +5,8 @@ import { themeComponent } from "../../../util/themeUtils";
5
5
 
6
6
  const NavMenuDesktop = ({
7
7
  id,
8
- top = "125%",
9
- left = "-100%",
8
+ top = "115%",
9
+ left = "-165%",
10
10
  menuContent = [],
11
11
  visible = true,
12
12
  onMouseEnter,
@@ -25,7 +25,7 @@ const NavMenuDesktop = ({
25
25
  extraStyles={`position: relative; ${menuCarat}`}
26
26
  background={themeValues.backgroundColor}
27
27
  borderRadius="5px"
28
- boxShadow={`0px 3px 8px 0px ${themeValues.shadowColor}, 0px 2px 14px 0px ${themeValues.shadowColor};`}
28
+ boxShadow={`0px 1px 8px -1px rgba(0, 0, 0, 0.3), 0px 1px 4px 0px ${themeValues.shadowColor}, 0px 7px 32px 0px ${themeValues.shadowColor}`}
29
29
  onMouseEnter={onMouseEnter}
30
30
  onMouseLeave={onMouseLeave}
31
31
  onFocus={onFocus}
@@ -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 { expirationDateFormat, creditCardFormat } from "../../../util/formats";
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,24 @@ 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
+ <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
+ />
67
90
  <FormInput
68
91
  labelTextWhenNoError="Name on card"
69
92
  errorMessages={nameOnCardErrors}
@@ -111,6 +134,8 @@ const PaymentFormCard = ({
111
134
  width={isMobile ? "100%" : "50%"}
112
135
  >
113
136
  <FormInput
137
+ isNum={isUS}
138
+ formatter={isUS ? zipFormat : null}
114
139
  labelTextWhenNoError="Zip code"
115
140
  errorMessages={zipCodeErrors}
116
141
  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: [required(), hasLength(5, 5)],
33
- constraints: [onlyIntegers(), hasLength(0, 5)]
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