@thecb/components 4.4.0-beta.1 → 4.4.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/dist/index.cjs.js CHANGED
@@ -6073,16 +6073,17 @@ var createUniqueId = function createUniqueId() {
6073
6073
 
6074
6074
  var safeChildren = function safeChildren(children) {
6075
6075
  var replacement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
6076
+ var unsafeValues = [false, undefined, NaN, null];
6076
6077
 
6077
6078
  if (children && children instanceof Array) {
6078
6079
  return children.map(function (child) {
6079
- return !child ? /*#__PURE__*/React__default.createElement(React.Fragment, {
6080
+ return unsafeValues.includes(child) ? /*#__PURE__*/React__default.createElement(React.Fragment, {
6080
6081
  key: createUniqueId()
6081
6082
  }, replacement) : child;
6082
6083
  });
6083
6084
  }
6084
6085
 
6085
- return !children ? replacement : children;
6086
+ return unsafeValues.includes(children) ? replacement : children;
6086
6087
  };
6087
6088
  var generateClickHandler = function generateClickHandler(form, handleErrors, submitForm) {
6088
6089
  return function (e) {
@@ -16402,7 +16403,7 @@ function parseToRgb(color) {
16402
16403
  };
16403
16404
  }
16404
16405
 
16405
- var rgbaMatched = rgbaRegex.exec(normalizedColor);
16406
+ var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
16406
16407
 
16407
16408
  if (rgbaMatched) {
16408
16409
  return {
@@ -16433,7 +16434,7 @@ function parseToRgb(color) {
16433
16434
  };
16434
16435
  }
16435
16436
 
16436
- var hslaMatched = hslaRegex.exec(normalizedColor);
16437
+ var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
16437
16438
 
16438
16439
  if (hslaMatched) {
16439
16440
  var _hue = parseInt("" + hslaMatched[1], 10);
@@ -40363,11 +40364,14 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
40363
40364
  showErrors = _ref.showErrors,
40364
40365
  _ref$handleSubmit = _ref.handleSubmit,
40365
40366
  handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
40366
- isMobile = _ref.isMobile,
40367
40367
  showWalletCheckbox = _ref.showWalletCheckbox,
40368
40368
  saveToWallet = _ref.saveToWallet,
40369
40369
  walletCheckboxMarked = _ref.walletCheckboxMarked,
40370
40370
  deniedCards = _ref.deniedCards;
40371
+
40372
+ var _useContext = React.useContext(styled.ThemeContext),
40373
+ isMobile = _useContext.isMobile;
40374
+
40371
40375
  React.useEffect(function () {
40372
40376
  if (deniedCards) {
40373
40377
  deniedCards.map(function (card) {
@@ -40431,7 +40435,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
40431
40435
  },
40432
40436
  isNum: true
40433
40437
  }), /*#__PURE__*/React__default.createElement(FormInputRow, {
40434
- breakpoint: "20rem"
40438
+ breakpoint: isMobile ? "1000rem" : "21rem",
40439
+ childGap: isMobile ? "0rem" : "1rem"
40435
40440
  }, /*#__PURE__*/React__default.createElement(FormInput$1, {
40436
40441
  labelTextWhenNoError: "Expiration date (MM/YY)",
40437
40442
  errorMessages: expirationDateErrors,
@@ -40476,6 +40481,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
40476
40481
  })));
40477
40482
  };
40478
40483
 
40484
+ var PaymentFormCard$1 = withWindowSize(PaymentFormCard);
40485
+
40479
40486
  var formConfig$8 = {
40480
40487
  country: {
40481
40488
  defaultValue: "US",
@@ -40507,9 +40514,9 @@ var _createFormState$8 = createFormState(formConfig$8),
40507
40514
  mapStateToProps$9 = _createFormState$8.mapStateToProps,
40508
40515
  mapDispatchToProps$8 = _createFormState$8.mapDispatchToProps;
40509
40516
 
40510
- PaymentFormCard.reducer = reducer$8;
40511
- PaymentFormCard.mapStateToProps = mapStateToProps$9;
40512
- PaymentFormCard.mapDispatchToProps = mapDispatchToProps$8;
40517
+ PaymentFormCard$1.reducer = reducer$8;
40518
+ PaymentFormCard$1.mapStateToProps = mapStateToProps$9;
40519
+ PaymentFormCard$1.mapDispatchToProps = mapDispatchToProps$8;
40513
40520
 
40514
40521
  var PhoneForm = function PhoneForm(_ref) {
40515
40522
  var _phoneErrorMessage;
@@ -41869,7 +41876,7 @@ exports.PasswordRequirements = PasswordRequirements;
41869
41876
  exports.PaymentButtonBar = PaymentButtonBar;
41870
41877
  exports.PaymentDetails = PaymentDetails$1;
41871
41878
  exports.PaymentFormACH = PaymentFormACH;
41872
- exports.PaymentFormCard = PaymentFormCard;
41879
+ exports.PaymentFormCard = PaymentFormCard$1;
41873
41880
  exports.PaymentIcon = PaymentIcon;
41874
41881
  exports.PaymentMethodAddIcon = PaymentMethodAddIcon$1;
41875
41882
  exports.PaymentMethodIcon = PaymentMethodIcon$1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "4.4.0-beta.1",
3
+ "version": "4.4.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,4 +1,5 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
2
3
  import { required, hasLength, matchesRegex } from "redux-freeform";
3
4
  import Checkbox from "../../atoms/checkbox";
4
5
  import CountryDropdown from "../../atoms/country-dropdown";
@@ -20,6 +21,7 @@ import {
20
21
  FormInputRow
21
22
  } from "../../atoms/form-layouts";
22
23
  import { Box } from "../../atoms/layouts";
24
+ import withWindowSize from "../../withWindowSize";
23
25
 
24
26
  const PaymentFormCard = ({
25
27
  variant = "default",
@@ -29,12 +31,12 @@ const PaymentFormCard = ({
29
31
  actions,
30
32
  showErrors,
31
33
  handleSubmit = noop,
32
- isMobile,
33
34
  showWalletCheckbox,
34
35
  saveToWallet,
35
36
  walletCheckboxMarked,
36
37
  deniedCards
37
38
  }) => {
39
+ const { isMobile } = useContext(ThemeContext);
38
40
  useEffect(() => {
39
41
  if (deniedCards) {
40
42
  deniedCards.map(card =>
@@ -116,7 +118,10 @@ const PaymentFormCard = ({
116
118
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
117
119
  isNum
118
120
  />
119
- <FormInputRow breakpoint="20rem">
121
+ <FormInputRow
122
+ breakpoint={isMobile ? "1000rem" : "21rem"}
123
+ childGap={isMobile ? "0rem" : "1rem"}
124
+ >
120
125
  <FormInput
121
126
  labelTextWhenNoError="Expiration date (MM/YY)"
122
127
  errorMessages={expirationDateErrors}
@@ -172,4 +177,4 @@ const PaymentFormCard = ({
172
177
  );
173
178
  };
174
179
 
175
- export default PaymentFormCard;
180
+ export default withWindowSize(PaymentFormCard);
@@ -17,12 +17,17 @@ const createUniqueId = () =>
17
17
  .substr(2, 9);
18
18
 
19
19
  export const safeChildren = (children, replacement = []) => {
20
+ const unsafeValues = [false, undefined, NaN, null];
20
21
  if (children && children instanceof Array) {
21
22
  return children.map(child =>
22
- !child ? <Fragment key={createUniqueId()}>{replacement}</Fragment> : child
23
+ unsafeValues.includes(child) ? (
24
+ <Fragment key={createUniqueId()}>{replacement}</Fragment>
25
+ ) : (
26
+ child
27
+ )
23
28
  );
24
29
  }
25
- return !children ? replacement : children;
30
+ return unsafeValues.includes(children) ? replacement : children;
26
31
  };
27
32
 
28
33
  export const generateClickHandler = (form, handleErrors, submitForm) => e => {