@thecb/components 6.1.0-beta.0 → 6.1.0-beta.4

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
@@ -4871,7 +4871,8 @@ var BOSTON_BLUE = "#357fb8";
4871
4871
  var INFO_BLUE = "#E4F4FD";
4872
4872
  var HOVER_LIGHT_BLUE = "#EFFAFF";
4873
4873
  var MATISSE_BLUE = "#15749D";
4874
- var ROYAL_BLUE = "#3181E3"; // GREEN
4874
+ var ROYAL_BLUE = "#3181E3";
4875
+ var ASTRAL_BLUE = "#3176AA"; // GREEN
4875
4876
 
4876
4877
  var FOREST_GREEN = "#19b03F";
4877
4878
  var MEADOW_GREEN = "#16C98D";
@@ -4893,7 +4894,7 @@ var APRICOT_ORANGE = "#FFE8D8"; // RED
4893
4894
  var RED = "#FF0000";
4894
4895
  var CRIMSON_RED = "#ED1C24";
4895
4896
  var THUNDERBIRD_RED = "#C3191F";
4896
- var RAZZMATAZZ_RED = "#ED125F";
4897
+ var RAZZMATAZZ_RED = "#D11053";
4897
4898
  var FANTASY_RED = "#FCF4F4";
4898
4899
  var COSMOS_RED = "#FFD0D3";
4899
4900
  var BLUSH_RED = "#FFF0F5"; // Second level color constants
@@ -4977,6 +4978,7 @@ var colors = /*#__PURE__*/Object.freeze({
4977
4978
  HOVER_LIGHT_BLUE: HOVER_LIGHT_BLUE,
4978
4979
  MATISSE_BLUE: MATISSE_BLUE,
4979
4980
  ROYAL_BLUE: ROYAL_BLUE,
4981
+ ASTRAL_BLUE: ASTRAL_BLUE,
4980
4982
  FOREST_GREEN: FOREST_GREEN,
4981
4983
  MEADOW_GREEN: MEADOW_GREEN,
4982
4984
  POLAR_GREEN: POLAR_GREEN,
@@ -6072,6 +6074,18 @@ var createUniqueId = function createUniqueId() {
6072
6074
  return "_" + Math.random().toString(36).substr(2, 9);
6073
6075
  };
6074
6076
 
6077
+ var createIdFromString = function createIdFromString(text, postscript) {
6078
+ var unique = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6079
+
6080
+ if (text === undefined) {
6081
+ return createUniqueId();
6082
+ } else {
6083
+ // "first name", undefined, false -> "first-name"
6084
+ // "email address", "error message", false -> "email-address-error-message"
6085
+ // "shopping cart", "order item", true -> "shopping-cart-order-item_2ahtlz608"
6086
+ return "".concat(text === null || text === void 0 ? void 0 : text.replace(/\s+/g, "-")).concat(postscript ? "-".concat(postscript === null || postscript === void 0 ? void 0 : postscript.replace(/\s+/g, "-")) : "").concat(unique ? createUniqueId() : "");
6087
+ }
6088
+ };
6075
6089
  var safeChildren = function safeChildren(children) {
6076
6090
  var replacement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
6077
6091
  var unsafeValues = [false, undefined, NaN, null];
@@ -6086,9 +6100,16 @@ var safeChildren = function safeChildren(children) {
6086
6100
 
6087
6101
  return unsafeValues.includes(children) ? replacement : children;
6088
6102
  };
6089
- var generateClickHandler = function generateClickHandler(form, handleErrors, submitForm) {
6103
+ var generateClickHandler = function generateClickHandler(form, handleErrors, submitForm, resetErrors) {
6090
6104
  return function (e) {
6091
6105
  e.preventDefault();
6106
+
6107
+ if (resetErrors) {
6108
+ // if provided, will reset error state tracker
6109
+ // allows hooks that depend on error state to re-run
6110
+ resetErrors();
6111
+ }
6112
+
6092
6113
  var formHasError = Object.values(form.fields).reduce(function (acc, curr) {
6093
6114
  return acc || curr.hasErrors;
6094
6115
  }, false);
@@ -6145,6 +6166,8 @@ var checkDeniedCards = function checkDeniedCards(name) {
6145
6166
  */
6146
6167
 
6147
6168
  var screenReaderOnlyStyle = "\n position: absolute;\n left: -10000px;\n top: auto;\n width: 1px;\n height: 1px;\n overflow: hidden;\n";
6169
+ var inputPlaceholderTextStyle = "\n ::-webkit-input-placeholder {\n color: ".concat(CHARADE_GREY, ";\n }\n ::-moz-placeholder {\n color: ").concat(CHARADE_GREY, ";\n }\n ::-ms-placeholder {\n color: ").concat(CHARADE_GREY, ";\n }\n ::placeholder {\n color: ").concat(CHARADE_GREY, ";\n }\n");
6170
+ var inputDisabledStyle = "\n color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;\n";
6148
6171
 
6149
6172
  var general = /*#__PURE__*/Object.freeze({
6150
6173
  __proto__: null,
@@ -6152,12 +6175,15 @@ var general = /*#__PURE__*/Object.freeze({
6152
6175
  displayCurrency: displayCurrency,
6153
6176
  convertCentsToMoneyInt: convertCentsToMoneyInt,
6154
6177
  formatPercent: formatPercent,
6178
+ createIdFromString: createIdFromString,
6155
6179
  safeChildren: safeChildren,
6156
6180
  generateClickHandler: generateClickHandler,
6157
6181
  checkCardBrand: checkCardBrand,
6158
6182
  displayCardBrand: displayCardBrand,
6159
6183
  checkDeniedCards: checkDeniedCards,
6160
- screenReaderOnlyStyle: screenReaderOnlyStyle
6184
+ screenReaderOnlyStyle: screenReaderOnlyStyle,
6185
+ inputPlaceholderTextStyle: inputPlaceholderTextStyle,
6186
+ inputDisabledStyle: inputDisabledStyle
6161
6187
  });
6162
6188
 
6163
6189
  var _excluded$1 = ["themeValues", "weight", "color", "textWrap", "extraStyles", "hoverStyles", "onClick", "onKeyPress", "as", "dataQa", "children"];
@@ -19032,13 +19058,13 @@ var disabledCheckedStyles = {
19032
19058
  "default": "\n background: #6d717e;\n border: 1px solid #6d717e;\n"
19033
19059
  };
19034
19060
  var disabledStyles = {
19035
- "default": "\n background: ".concat(SEASHELL_WHITE, ";\n border: 1px solid ").concat(GHOST_GREY, ";\n")
19061
+ "default": "\n background: ".concat(SEASHELL_WHITE, ";\n border: 1px solid ").concat(STORM_GREY, ";\n")
19036
19062
  };
19037
19063
  var checkedStyles = {
19038
19064
  "default": "\n background: ".concat(MATISSE_BLUE, "; \n border: 1px solid ").concat(MATISSE_BLUE, ";\n")
19039
19065
  };
19040
19066
  var defaultStyles = {
19041
- "default": "\n background: ".concat(WHITE, "; \n border: 1px solid ").concat(GHOST_GREY, ";\n")
19067
+ "default": "\n background: ".concat(WHITE, "; \n border: 1px solid ").concat(STORM_GREY, ";\n")
19042
19068
  };
19043
19069
  var fallbackValues$c = {
19044
19070
  backgroundColor: backgroundColor$2,
@@ -20714,6 +20740,7 @@ var Dropdown = function Dropdown(_ref8) {
20714
20740
  _ref8$autoEraseTypeAh = _ref8.autoEraseTypeAhead,
20715
20741
  autoEraseTypeAhead = _ref8$autoEraseTypeAh === void 0 ? true : _ref8$autoEraseTypeAh,
20716
20742
  ariaLabelledby = _ref8.ariaLabelledby,
20743
+ ariaDescribedby = _ref8.ariaDescribedby,
20717
20744
  _ref8$autocompleteVal = _ref8.autocompleteValue,
20718
20745
  autocompleteValue = _ref8$autocompleteVal === void 0 ? "" : _ref8$autocompleteVal,
20719
20746
  _ref8$smoothScroll = _ref8.smoothScroll,
@@ -20963,13 +20990,14 @@ var Dropdown = function Dropdown(_ref8) {
20963
20990
  "aria-owns": "".concat(ariaLabelledby, "_listbox"),
20964
20991
  "aria-haspopup": "listbox",
20965
20992
  "aria-labelledby": ariaLabelledby,
20993
+ "aria-describedby": ariaDescribedby,
20966
20994
  "aria-expanded": isOpen,
20967
20995
  autocomplete: autocompleteValue,
20968
20996
  background: isOpen ? themeValues.hoverColor : WHITE,
20969
20997
  borderRadius: "2px",
20970
20998
  borderSize: "1px",
20971
20999
  borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
20972
- extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
21000
+ extraStyles: disabled ? "".concat(inputPlaceholderTextStyle).concat(inputDisabledStyle) : inputPlaceholderTextStyle,
20973
21001
  hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
20974
21002
  isOpen: isOpen,
20975
21003
  minHeight: "48px",
@@ -21179,9 +21207,10 @@ var FormSelect = function FormSelect(_ref) {
21179
21207
  color: themeValues.labelColor,
21180
21208
  weight: themeValues.fontWeight,
21181
21209
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
21182
- id: labelTextWhenNoError.replace(/\s+/g, "-")
21210
+ id: createIdFromString(labelTextWhenNoError)
21183
21211
  }, labelTextWhenNoError))), /*#__PURE__*/React__default.createElement(Dropdown$1, {
21184
- ariaLabelledby: labelTextWhenNoError.replace(/\s+/g, "-"),
21212
+ ariaLabelledby: createIdFromString(labelTextWhenNoError),
21213
+ ariaDescribedby: createIdFromString(labelTextWhenNoError, "error message"),
21185
21214
  maxHeight: dropdownMaxHeight,
21186
21215
  hasTitles: hasTitles,
21187
21216
  placeholder: options[0] ? options[0].text : "",
@@ -21208,7 +21237,8 @@ var FormSelect = function FormSelect(_ref) {
21208
21237
  color: ERROR_COLOR,
21209
21238
  variant: "pXS",
21210
21239
  weight: themeValues.fontWeight,
21211
- extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
21240
+ extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
21241
+ id: createIdFromString(labelTextWhenNoError, "error message")
21212
21242
  }, errorMessages[field.errors[0]]) : /*#__PURE__*/React__default.createElement(Text$1, {
21213
21243
  extraStyles: "height: ".concat(themeValues.lineHeight, ";")
21214
21244
  })));
@@ -22483,8 +22513,8 @@ var labelColor$1 = {
22483
22513
  disabled: "".concat(CHARADE_GREY)
22484
22514
  };
22485
22515
  var borderColor$1 = {
22486
- "default": "".concat(GREY_CHATEAU),
22487
- disabled: "".concat(GREY_CHATEAU)
22516
+ "default": "".concat(STORM_GREY),
22517
+ disabled: "".concat(STORM_GREY)
22488
22518
  };
22489
22519
  var lineHeight$2 = {
22490
22520
  "default": "1rem",
@@ -22631,7 +22661,7 @@ var FormInput = function FormInput(_ref15) {
22631
22661
  variant: "pS",
22632
22662
  weight: themeValues.fontWeight,
22633
22663
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
22634
- id: labelTextWhenNoError.replace(/\s+/g, "-")
22664
+ id: createIdFromString(labelTextWhenNoError)
22635
22665
  }, labelTextWhenNoError), /*#__PURE__*/React__default.createElement(Text$1, {
22636
22666
  color: themeValues.linkColor,
22637
22667
  variant: "pS",
@@ -22648,7 +22678,7 @@ var FormInput = function FormInput(_ref15) {
22648
22678
  variant: "pS",
22649
22679
  fontWeight: themeValues.fontWeight,
22650
22680
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
22651
- id: labelTextWhenNoError.replace(/\s+/g, "-")
22681
+ id: createIdFromString(labelTextWhenNoError)
22652
22682
  }, labelTextWhenNoError), type === "password" && /*#__PURE__*/React__default.createElement(Text$1, {
22653
22683
  variant: "pS",
22654
22684
  color: themeValues.linkColor,
@@ -22668,7 +22698,9 @@ var FormInput = function FormInput(_ref15) {
22668
22698
  }, decorator)))), /*#__PURE__*/React__default.createElement(Box, {
22669
22699
  padding: "0"
22670
22700
  }, formatter ? /*#__PURE__*/React__default.createElement(FormattedInputField, _extends({
22671
- "aria-labelledby": labelTextWhenNoError.replace(/\s+/g, "-"),
22701
+ "aria-labelledby": createIdFromString(labelTextWhenNoError),
22702
+ "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
22703
+ "aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
22672
22704
  onChange: function onChange(e) {
22673
22705
  return fieldActions.set(e);
22674
22706
  },
@@ -22684,7 +22716,9 @@ var FormInput = function FormInput(_ref15) {
22684
22716
  $customHeight: customHeight,
22685
22717
  $extraStyles: extraStyles
22686
22718
  }, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
22687
- "aria-labelledby": labelTextWhenNoError.replace(/\s+/g, "-"),
22719
+ "aria-labelledby": createIdFromString(labelTextWhenNoError),
22720
+ "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
22721
+ "aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
22688
22722
  onChange: function onChange(e) {
22689
22723
  return fieldActions.set(e.target.value);
22690
22724
  },
@@ -22706,7 +22740,8 @@ var FormInput = function FormInput(_ref15) {
22706
22740
  color: ERROR_COLOR,
22707
22741
  variant: "pXS",
22708
22742
  weight: themeValues.fontWeight,
22709
- extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
22743
+ extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
22744
+ id: createIdFromString(labelTextWhenNoError, "error message")
22710
22745
  }, errorMessages[field.errors[0]]) : /*#__PURE__*/React__default.createElement(Text$1, {
22711
22746
  extraStyles: "height: ".concat(themeValues.lineHeight, ";")
22712
22747
  }), !isMobile && decorator && /*#__PURE__*/React__default.createElement(Box, {
@@ -40242,6 +40277,8 @@ var getApplicationNode = function getApplicationNode() {
40242
40277
  var Modal$1 = function Modal(_ref) {
40243
40278
  var hideModal = _ref.hideModal,
40244
40279
  continueAction = _ref.continueAction,
40280
+ _ref$isContinueAction = _ref.isContinueActionDisabled,
40281
+ isContinueActionDisabled = _ref$isContinueAction === void 0 ? false : _ref$isContinueAction,
40245
40282
  cancelAction = _ref.cancelAction,
40246
40283
  modalOpen = _ref.modalOpen,
40247
40284
  modalHeaderText = _ref.modalHeaderText,
@@ -40260,6 +40297,8 @@ var Modal$1 = function Modal(_ref) {
40260
40297
  defaultWrapper = _ref$defaultWrapper === void 0 ? true : _ref$defaultWrapper,
40261
40298
  _ref$onlyCloseButton = _ref.onlyCloseButton,
40262
40299
  onlyCloseButton = _ref$onlyCloseButton === void 0 ? false : _ref$onlyCloseButton,
40300
+ _ref$noButtons = _ref.noButtons,
40301
+ noButtons = _ref$noButtons === void 0 ? false : _ref$noButtons,
40263
40302
  maxHeight = _ref.maxHeight,
40264
40303
  _ref$underlayClickExi = _ref.underlayClickExits,
40265
40304
  underlayClickExits = _ref$underlayClickExi === void 0 ? true : _ref$underlayClickExi,
@@ -40320,7 +40359,7 @@ var Modal$1 = function Modal(_ref) {
40320
40359
  justify: "flex-end",
40321
40360
  align: "center",
40322
40361
  childGap: "0rem"
40323
- }, !onlyCloseButton ? /*#__PURE__*/React__default.createElement(React.Fragment, null, isMobile ? /*#__PURE__*/React__default.createElement(Stack, {
40362
+ }, !noButtons && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !onlyCloseButton ? /*#__PURE__*/React__default.createElement(React.Fragment, null, isMobile ? /*#__PURE__*/React__default.createElement(Stack, {
40324
40363
  childGap: "1rem",
40325
40364
  direction: "row"
40326
40365
  }, /*#__PURE__*/React__default.createElement(Box, {
@@ -40342,6 +40381,7 @@ var Modal$1 = function Modal(_ref) {
40342
40381
  text: continueButtonText,
40343
40382
  dataQa: continueButtonText,
40344
40383
  isLoading: isLoading,
40384
+ disabled: isContinueActionDisabled,
40345
40385
  extraStyles: buttonExtraStyles,
40346
40386
  className: "modal-continue-button"
40347
40387
  }))) : /*#__PURE__*/React__default.createElement(Stack, {
@@ -40361,6 +40401,7 @@ var Modal$1 = function Modal(_ref) {
40361
40401
  text: continueButtonText,
40362
40402
  dataQa: continueButtonText,
40363
40403
  isLoading: isLoading,
40404
+ disabled: isContinueActionDisabled,
40364
40405
  extraStyles: buttonExtraStyles,
40365
40406
  className: "modal-continue-button"
40366
40407
  }))) : /*#__PURE__*/React__default.createElement(Box, {
@@ -40372,7 +40413,7 @@ var Modal$1 = function Modal(_ref) {
40372
40413
  dataQa: "Close",
40373
40414
  extraStyles: buttonExtraStyles,
40374
40415
  className: "modal-cancel-button"
40375
- })))))))), children);
40416
+ }))))))))), children);
40376
40417
  };
40377
40418
 
40378
40419
  var fontSize$9 = {
@@ -40645,7 +40686,7 @@ var TitleModule = function TitleModule(_ref) {
40645
40686
  var color$a = "#15749D";
40646
40687
  var hoverColor$4 = "#116285";
40647
40688
  var activeColor$5 = "#0E506D";
40648
- var linkColor$3 = "#357fb8";
40689
+ var linkColor$3 = "#3176AA";
40649
40690
  var fontWeight$6 = FONT_WEIGHT_REGULAR;
40650
40691
  var modalLinkHoverFocus = "outline: none;\n cursor: pointer;\n text-decoration: underline;\n text-decoration-color: #317D4F;";
40651
40692
  var fallbackValues$z = {
@@ -41826,7 +41867,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
41826
41867
  var PaymentDetails$1 = themeComponent(PaymentDetails, "PaymentDetails", fallbackValues$A, "default");
41827
41868
 
41828
41869
  var linkColor$4 = {
41829
- "default": "#357fb8"
41870
+ "default": "#3176AA"
41830
41871
  };
41831
41872
  var fontSize$a = {
41832
41873
  "default": "1rem"
@@ -42980,7 +43021,7 @@ var backgroundColor$9 = {
42980
43021
  footer: "#ffffff"
42981
43022
  };
42982
43023
  var linkColor$5 = {
42983
- "default": "#357fb8",
43024
+ "default": "#3176AA",
42984
43025
  footer: "#ffffff"
42985
43026
  };
42986
43027
  var border$3 = {
@@ -43040,7 +43081,8 @@ var TermsAndConditionsModal = function TermsAndConditionsModal(_ref) {
43040
43081
  borderRadius: "3px",
43041
43082
  extraStyles: "overflow: scroll; max-height: 20rem;"
43042
43083
  }, /*#__PURE__*/React__default.createElement(Text$1, {
43043
- variant: "p"
43084
+ variant: "p",
43085
+ extraStyles: "& a { text-decoration: underline; }"
43044
43086
  }, terms)),
43045
43087
  defaultWrapper: false,
43046
43088
  onlyCloseButton: !acceptText,
@@ -43284,6 +43326,9 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
43284
43326
  time.timer = setTimeout(function () {
43285
43327
  periscopeDataRequestFailure();
43286
43328
  }, 10000);
43329
+ return function () {
43330
+ return clearTimeout(time.timer);
43331
+ };
43287
43332
  }, []);
43288
43333
 
43289
43334
  var Dashboard = function Dashboard(height) {
@@ -43304,8 +43349,11 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
43304
43349
  var validatePeriscope = function validatePeriscope(message) {
43305
43350
  if (isValidMessage(message)) {
43306
43351
  setHeight(message.data.dashboard_height + 100);
43307
- clearTimeout(time.timer);
43308
- periscopeDataRequestSuccess();
43352
+
43353
+ if (!periscopeDataSuccess) {
43354
+ clearTimeout(time.timer);
43355
+ periscopeDataRequestSuccess();
43356
+ }
43309
43357
  }
43310
43358
  };
43311
43359
 
@@ -43614,13 +43662,33 @@ var index$4 = /*#__PURE__*/Object.freeze({
43614
43662
  fontWeights: style_constants
43615
43663
  });
43616
43664
 
43665
+ var useFocusInvalidInput = function useFocusInvalidInput() {
43666
+ var showErrors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
43667
+ console.log("hey show errors", showErrors); // Only move focus when "showErrors" is true
43668
+ // "showErrors" is managed by container page of form
43669
+ // typically set to "true" on attempted form submission, if errors exist
43670
+
43671
+ React.useEffect(function () {
43672
+ console.log("inside use effect show errors", showErrors);
43673
+
43674
+ if (showErrors) {
43675
+ var _inputsWithErrors$;
43676
+
43677
+ var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
43678
+ console.log("inputs with errors is", inputsWithErrors);
43679
+ inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
43680
+ }
43681
+ }, [showErrors]);
43682
+ };
43683
+
43617
43684
 
43618
43685
 
43619
43686
  var index$5 = /*#__PURE__*/Object.freeze({
43620
43687
  __proto__: null,
43621
43688
  formats: formats,
43622
43689
  general: general,
43623
- theme: themeUtils
43690
+ theme: themeUtils,
43691
+ useFocusInvalidInput: useFocusInvalidInput
43624
43692
  });
43625
43693
 
43626
43694
  exports.AccountNumberImage = AccountNumberImage;