@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.cjs.js CHANGED
@@ -22155,8 +22155,9 @@ var ARROW_DOWN = 40;
22155
22155
  var ENTER = 13;
22156
22156
  var ESCAPE = 27;
22157
22157
  var SPACEBAR = 32;
22158
+ var SPACE_KEY = " ";
22158
22159
 
22159
- var _excluded$x = ["title", "name", "checked", "onChange", "disabled", "themeValues", "hidden", "error", "isRequired", "checkboxMargin", "extraStyles", "textExtraStyles", "labelledById", "dataQa", "checkboxExtraStyles", "hasIconOverride", "icon"];
22160
+ var _excluded$x = ["title", "name", "checked", "onChange", "disabled", "themeValues", "hidden", "error", "isRequired", "checkboxMargin", "extraStyles", "textExtraStyles", "labelledById", "dataQa", "checkboxExtraStyles", "hasIconOverride", "icon", "customAriaLabel"];
22160
22161
  var CheckboxContainer = styled__default.span.withConfig({
22161
22162
  displayName: "Checkbox__CheckboxContainer",
22162
22163
  componentId: "sc-36kqbv-0"
@@ -22228,19 +22229,24 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
22228
22229
  _ref5$hasIconOverride = _ref5.hasIconOverride,
22229
22230
  hasIconOverride = _ref5$hasIconOverride === void 0 ? false : _ref5$hasIconOverride,
22230
22231
  Icon = _ref5.icon,
22232
+ customAriaLabel = _ref5.customAriaLabel,
22231
22233
  rest = _objectWithoutProperties(_ref5, _excluded$x);
22232
22234
  var _useState = React.useState(false),
22233
22235
  _useState2 = _slicedToArray(_useState, 2),
22234
22236
  focused = _useState2[0],
22235
22237
  setFocused = _useState2[1];
22236
22238
  var handleClick = function handleClick(e, func) {
22237
- if (e.keyCode === ENTER) {
22239
+ if (e.key === SPACE_KEY) {
22240
+ e.preventDefault();
22238
22241
  func();
22239
22242
  }
22240
22243
  };
22241
- var titleId = title ? "checkboxlabel-".concat(name) : undefined;
22242
- var ariaLabelledById = labelledById !== null && labelledById !== void 0 ? labelledById : titleId;
22243
- var ariaLabel = ariaLabelledById ? undefined : name;
22244
+ var normalizeName = name ? name.replace(/\s+/g, "-") : "";
22245
+ var checkboxId = "checkbox-".concat(normalizeName);
22246
+ var titleId = title ? "checkboxlabel-".concat(normalizeName) : undefined;
22247
+ var ariaLabelledById = customAriaLabel ? undefined : labelledById !== null && labelledById !== void 0 ? labelledById : titleId;
22248
+ var ariaLabel = ariaLabelledById ? undefined : customAriaLabel !== null && customAriaLabel !== void 0 ? customAriaLabel : name;
22249
+ var errorMessageNormalized = error ? "".concat(normalizeName, "-error-message") : undefined;
22244
22250
  return /*#__PURE__*/React__default.createElement(Box, _extends({
22245
22251
  ref: ref,
22246
22252
  padding: "0",
@@ -22251,7 +22257,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
22251
22257
  "aria-invalid": error,
22252
22258
  "aria-label": ariaLabel,
22253
22259
  "aria-labelledby": ariaLabelledById,
22254
- "aria-describedby": error ? "".concat(name, "-error-message") : undefined,
22260
+ "aria-describedby": errorMessageNormalized,
22255
22261
  onFocus: function onFocus() {
22256
22262
  return setFocused(true);
22257
22263
  },
@@ -22269,7 +22275,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
22269
22275
  }, /*#__PURE__*/React__default.createElement(CheckboxContainer, {
22270
22276
  "data-qa": "Checkbox"
22271
22277
  }, /*#__PURE__*/React__default.createElement(HiddenCheckbox, {
22272
- id: "checkbox-".concat(name),
22278
+ id: checkboxId,
22273
22279
  disabled: disabled,
22274
22280
  name: name,
22275
22281
  checked: checked,
@@ -48195,6 +48201,10 @@ var TermsAndConditionsControlV1 = function TermsAndConditionsControlV1(_ref) {
48195
48201
  };
48196
48202
 
48197
48203
  var TermsAndConditionsTitleDivId = "terms-and-conditions-title";
48204
+ var InlineTermsWrapper = styled__default.span.withConfig({
48205
+ displayName: "TermsAndConditionsControlV2__InlineTermsWrapper",
48206
+ componentId: "sc-16np073-0"
48207
+ })(["display:inline;> div{display:inline;}.modal-trigger{display:inline !important;}"]);
48198
48208
  var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
48199
48209
  var _ref$showCheckbox = _ref.showCheckbox,
48200
48210
  showCheckbox = _ref$showCheckbox === void 0 ? true : _ref$showCheckbox,
@@ -48236,6 +48246,21 @@ var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
48236
48246
  useScrollTo("terms-body-text", 0, 0, "smooth", 100);
48237
48247
  }
48238
48248
  };
48249
+ if (!showCheckbox && displayInline) {
48250
+ return /*#__PURE__*/React__default.createElement(InlineTermsWrapper, {
48251
+ id: TermsAndConditionsTitleDivId
48252
+ }, description && /*#__PURE__*/React__default.createElement(Text$1, {
48253
+ color: CHARADE_GREY
48254
+ }, description), terms && /*#__PURE__*/React__default.createElement(TermsAndConditionsModal$1, {
48255
+ link: linkText,
48256
+ terms: terms,
48257
+ isOpen: showTerms,
48258
+ toggleOpen: toggleTerms,
48259
+ linkVariant: modalVariant,
48260
+ title: modalTitle,
48261
+ initialFocusSelector: initialFocusSelector
48262
+ }));
48263
+ }
48239
48264
  return /*#__PURE__*/React__default.createElement(Box, {
48240
48265
  padding: displayInline ? "0" : "1.5rem",
48241
48266
  minWidth: displayInline ? "0" : "100%",
@@ -48448,25 +48473,33 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
48448
48473
  onChange: toggleCheckbox,
48449
48474
  checked: defaultMethod.value,
48450
48475
  hidden: hideDefaultPayment
48451
- }), (showWalletCheckbox || showTerms) && /*#__PURE__*/React__default.createElement(Cluster, {
48452
- childGap: "4px",
48453
- align: "center",
48454
- overflow: true
48455
- }, showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48476
+ }), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48456
48477
  name: "bank checkbox",
48457
48478
  dataQa: "Save checking account to wallet",
48458
- title: "Save checking account to wallet.",
48479
+ customAriaLabel: "Save checking account to wallet (optional).",
48480
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "Save checking account to wallet (optional).", " ", showTerms && /*#__PURE__*/React__default.createElement("span", {
48481
+ onClick: function onClick(e) {
48482
+ return e.stopPropagation();
48483
+ },
48484
+ style: {
48485
+ display: "inline"
48486
+ }
48487
+ }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48488
+ version: "v2",
48489
+ showCheckbox: false,
48490
+ description: "View ",
48491
+ terms: termsContent,
48492
+ initialFocusSelector: ".modal-close-button"
48493
+ }))),
48459
48494
  checked: walletCheckboxMarked,
48460
48495
  onChange: saveToWallet
48461
- }), showTerms && /*#__PURE__*/React__default.createElement(Cover, {
48462
- singleChild: true
48463
- }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48496
+ }), !showWalletCheckbox && showTerms && /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48464
48497
  version: "v2",
48465
48498
  showCheckbox: false,
48466
- description: "View",
48499
+ description: "View ",
48467
48500
  terms: termsContent,
48468
48501
  initialFocusSelector: ".modal-close-button"
48469
- })))));
48502
+ })));
48470
48503
  };
48471
48504
 
48472
48505
  var formConfig$6 = {
@@ -48638,25 +48671,33 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
48638
48671
  },
48639
48672
  autocompleteValue: "billing postal-code",
48640
48673
  isRequired: true
48641
- })), (showWalletCheckbox || showTerms) && /*#__PURE__*/React__default.createElement(Cluster, {
48642
- childGap: "4px",
48643
- align: "center",
48644
- overflow: true
48645
- }, showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48674
+ })), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
48646
48675
  name: "credit card checkbox",
48647
48676
  dataQa: "Save credit card to wallet",
48648
- title: "Save credit card to wallet.",
48677
+ customAriaLabel: "Save credit card to wallet (optional).",
48678
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "Save credit card to wallet (optional).", " ", showTerms && /*#__PURE__*/React__default.createElement("span", {
48679
+ onClick: function onClick(e) {
48680
+ return e.stopPropagation();
48681
+ },
48682
+ style: {
48683
+ display: "inline"
48684
+ }
48685
+ }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48686
+ version: "v2",
48687
+ showCheckbox: false,
48688
+ description: "View ",
48689
+ terms: termsContent,
48690
+ initialFocusSelector: ".modal-close-button"
48691
+ }))),
48649
48692
  checked: walletCheckboxMarked,
48650
48693
  onChange: saveToWallet
48651
- }), showTerms && /*#__PURE__*/React__default.createElement(Cover, {
48652
- singleChild: true
48653
- }, /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48694
+ }), !showWalletCheckbox && showTerms && /*#__PURE__*/React__default.createElement(TermsAndConditions, {
48654
48695
  version: "v2",
48655
48696
  showCheckbox: false,
48656
- description: "View",
48697
+ description: "View ",
48657
48698
  terms: termsContent,
48658
48699
  initialFocusSelector: ".modal-close-button"
48659
- })))));
48700
+ })));
48660
48701
  };
48661
48702
  var PaymentFormCard$1 = withWindowSize(PaymentFormCard);
48662
48703