@thecb/components 12.1.0-beta.12 → 12.1.0-beta.14

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.esm.js CHANGED
@@ -22147,8 +22147,9 @@ var ARROW_DOWN = 40;
22147
22147
  var ENTER = 13;
22148
22148
  var ESCAPE = 27;
22149
22149
  var SPACEBAR = 32;
22150
+ var SPACE_KEY = " ";
22150
22151
 
22151
- var _excluded$x = ["title", "name", "checked", "onChange", "disabled", "themeValues", "hidden", "error", "isRequired", "checkboxMargin", "extraStyles", "textExtraStyles", "labelledById", "dataQa", "checkboxExtraStyles", "hasIconOverride", "icon"];
22152
+ var _excluded$x = ["title", "name", "checked", "onChange", "disabled", "themeValues", "hidden", "error", "isRequired", "checkboxMargin", "extraStyles", "textExtraStyles", "labelledById", "dataQa", "checkboxExtraStyles", "hasIconOverride", "icon", "customAriaLabel"];
22152
22153
  var CheckboxContainer = styled.span.withConfig({
22153
22154
  displayName: "Checkbox__CheckboxContainer",
22154
22155
  componentId: "sc-36kqbv-0"
@@ -22220,19 +22221,24 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref5, ref) {
22220
22221
  _ref5$hasIconOverride = _ref5.hasIconOverride,
22221
22222
  hasIconOverride = _ref5$hasIconOverride === void 0 ? false : _ref5$hasIconOverride,
22222
22223
  Icon = _ref5.icon,
22224
+ customAriaLabel = _ref5.customAriaLabel,
22223
22225
  rest = _objectWithoutProperties(_ref5, _excluded$x);
22224
22226
  var _useState = useState(false),
22225
22227
  _useState2 = _slicedToArray(_useState, 2),
22226
22228
  focused = _useState2[0],
22227
22229
  setFocused = _useState2[1];
22228
22230
  var handleClick = function handleClick(e, func) {
22229
- if (e.keyCode === ENTER) {
22231
+ if (e.key === SPACE_KEY) {
22232
+ e.preventDefault();
22230
22233
  func();
22231
22234
  }
22232
22235
  };
22233
- var titleId = title ? "checkboxlabel-".concat(name) : undefined;
22234
- var ariaLabelledById = labelledById !== null && labelledById !== void 0 ? labelledById : titleId;
22235
- var ariaLabel = ariaLabelledById ? undefined : name;
22236
+ var normalizeName = name ? name.replace(/\s+/g, "-") : "";
22237
+ var checkboxId = "checkbox-".concat(normalizeName);
22238
+ var titleId = title ? "checkboxlabel-".concat(normalizeName) : undefined;
22239
+ var ariaLabelledById = customAriaLabel ? undefined : labelledById !== null && labelledById !== void 0 ? labelledById : titleId;
22240
+ var ariaLabel = ariaLabelledById ? undefined : customAriaLabel !== null && customAriaLabel !== void 0 ? customAriaLabel : name;
22241
+ var errorMessageNormalized = error ? "".concat(normalizeName, "-error-message") : undefined;
22236
22242
  return /*#__PURE__*/React__default.createElement(Box, _extends({
22237
22243
  ref: ref,
22238
22244
  padding: "0",
@@ -22243,7 +22249,7 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref5, ref) {
22243
22249
  "aria-invalid": error,
22244
22250
  "aria-label": ariaLabel,
22245
22251
  "aria-labelledby": ariaLabelledById,
22246
- "aria-describedby": error ? "".concat(name, "-error-message") : undefined,
22252
+ "aria-describedby": errorMessageNormalized,
22247
22253
  onFocus: function onFocus() {
22248
22254
  return setFocused(true);
22249
22255
  },
@@ -22261,7 +22267,7 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref5, ref) {
22261
22267
  }, /*#__PURE__*/React__default.createElement(CheckboxContainer, {
22262
22268
  "data-qa": "Checkbox"
22263
22269
  }, /*#__PURE__*/React__default.createElement(HiddenCheckbox, {
22264
- id: "checkbox-".concat(name),
22270
+ id: checkboxId,
22265
22271
  disabled: disabled,
22266
22272
  name: name,
22267
22273
  checked: checked,
@@ -48187,6 +48193,10 @@ var TermsAndConditionsControlV1 = function TermsAndConditionsControlV1(_ref) {
48187
48193
  };
48188
48194
 
48189
48195
  var TermsAndConditionsTitleDivId = "terms-and-conditions-title";
48196
+ var InlineTermsWrapper = styled.span.withConfig({
48197
+ displayName: "TermsAndConditionsControlV2__InlineTermsWrapper",
48198
+ componentId: "sc-16np073-0"
48199
+ })(["display:inline;> div{display:inline;}.modal-trigger{display:inline !important;}"]);
48190
48200
  var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
48191
48201
  var _ref$showCheckbox = _ref.showCheckbox,
48192
48202
  showCheckbox = _ref$showCheckbox === void 0 ? true : _ref$showCheckbox,
@@ -48228,6 +48238,21 @@ var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
48228
48238
  useScrollTo("terms-body-text", 0, 0, "smooth", 100);
48229
48239
  }
48230
48240
  };
48241
+ if (!showCheckbox && displayInline) {
48242
+ return /*#__PURE__*/React__default.createElement(InlineTermsWrapper, {
48243
+ id: TermsAndConditionsTitleDivId
48244
+ }, description && /*#__PURE__*/React__default.createElement(Text$1, {
48245
+ color: CHARADE_GREY
48246
+ }, description), terms && /*#__PURE__*/React__default.createElement(TermsAndConditionsModal$1, {
48247
+ link: linkText,
48248
+ terms: terms,
48249
+ isOpen: showTerms,
48250
+ toggleOpen: toggleTerms,
48251
+ linkVariant: modalVariant,
48252
+ title: modalTitle,
48253
+ initialFocusSelector: initialFocusSelector
48254
+ }));
48255
+ }
48231
48256
  return /*#__PURE__*/React__default.createElement(Box, {
48232
48257
  padding: displayInline ? "0" : "1.5rem",
48233
48258
  minWidth: displayInline ? "0" : "100%",
@@ -48440,25 +48465,33 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
48440
48465
  onChange: toggleCheckbox,
48441
48466
  checked: defaultMethod.value,
48442
48467
  hidden: hideDefaultPayment
48443
- }), (showWalletCheckbox || showTerms) && /*#__PURE__*/React__default.createElement(Cluster, {
48444
- childGap: "4px",
48445
- align: "center",
48446
- overflow: true
48447
- }, showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48468
+ }), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48448
48469
  name: "bank checkbox",
48449
48470
  dataQa: "Save checking account to wallet",
48450
- title: "Save checking account to wallet.",
48471
+ customAriaLabel: "Save checking account to wallet (optional).",
48472
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "Save checking account to wallet (optional).", " ", showTerms && /*#__PURE__*/React__default.createElement("span", {
48473
+ onClick: function onClick(e) {
48474
+ return e.stopPropagation();
48475
+ },
48476
+ style: {
48477
+ display: "inline"
48478
+ }
48479
+ }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48480
+ version: "v2",
48481
+ showCheckbox: false,
48482
+ description: "View ",
48483
+ terms: termsContent,
48484
+ initialFocusSelector: ".modal-close-button"
48485
+ }))),
48451
48486
  checked: walletCheckboxMarked,
48452
48487
  onChange: saveToWallet
48453
- }), showTerms && /*#__PURE__*/React__default.createElement(Cover, {
48454
- singleChild: true
48455
- }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48488
+ }), !showWalletCheckbox && showTerms && /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48456
48489
  version: "v2",
48457
48490
  showCheckbox: false,
48458
- description: "View",
48491
+ description: "View ",
48459
48492
  terms: termsContent,
48460
48493
  initialFocusSelector: ".modal-close-button"
48461
- })))));
48494
+ })));
48462
48495
  };
48463
48496
 
48464
48497
  var formConfig$6 = {
@@ -48630,25 +48663,33 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
48630
48663
  },
48631
48664
  autocompleteValue: "billing postal-code",
48632
48665
  isRequired: true
48633
- })), (showWalletCheckbox || showTerms) && /*#__PURE__*/React__default.createElement(Cluster, {
48634
- childGap: "4px",
48635
- align: "center",
48636
- overflow: true
48637
- }, showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48666
+ })), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48638
48667
  name: "credit card checkbox",
48639
48668
  dataQa: "Save credit card to wallet",
48640
- title: "Save credit card to wallet.",
48669
+ customAriaLabel: "Save credit card to wallet (optional).",
48670
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "Save credit card to wallet (optional).", " ", showTerms && /*#__PURE__*/React__default.createElement("span", {
48671
+ onClick: function onClick(e) {
48672
+ return e.stopPropagation();
48673
+ },
48674
+ style: {
48675
+ display: "inline"
48676
+ }
48677
+ }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48678
+ version: "v2",
48679
+ showCheckbox: false,
48680
+ description: "View ",
48681
+ terms: termsContent,
48682
+ initialFocusSelector: ".modal-close-button"
48683
+ }))),
48641
48684
  checked: walletCheckboxMarked,
48642
48685
  onChange: saveToWallet
48643
- }), showTerms && /*#__PURE__*/React__default.createElement(Cover, {
48644
- singleChild: true
48645
- }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48686
+ }), !showWalletCheckbox && showTerms && /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48646
48687
  version: "v2",
48647
48688
  showCheckbox: false,
48648
- description: "View",
48689
+ description: "View ",
48649
48690
  terms: termsContent,
48650
48691
  initialFocusSelector: ".modal-close-button"
48651
- })))));
48692
+ })));
48652
48693
  };
48653
48694
  var PaymentFormCard$1 = withWindowSize(PaymentFormCard);
48654
48695