@thecb/components 10.7.6-beta.0 → 10.7.7

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
@@ -27106,6 +27106,10 @@ var FormInput = function FormInput(_ref15) {
27106
27106
  _useState2 = _slicedToArray(_useState, 2),
27107
27107
  showPassword = _useState2[0],
27108
27108
  setShowPassword = _useState2[1];
27109
+ var _useState3 = React.useState(false),
27110
+ _useState4 = _slicedToArray(_useState3, 2),
27111
+ isFocused = _useState4[0],
27112
+ setIsFocused = _useState4[1];
27109
27113
  var _useContext = React.useContext(styled.ThemeContext),
27110
27114
  isMobile = _useContext.isMobile;
27111
27115
  var setValue = function setValue(value) {
@@ -27119,6 +27123,7 @@ var FormInput = function FormInput(_ref15) {
27119
27123
  if (isRequired && value === "") {
27120
27124
  setValue("");
27121
27125
  }
27126
+ setIsFocused(false);
27122
27127
  };
27123
27128
  return /*#__PURE__*/React__default.createElement(Stack, {
27124
27129
  childGap: "0.25rem"
@@ -27189,6 +27194,15 @@ var FormInput = function FormInput(_ref15) {
27189
27194
  "data-qa": dataQa || labelTextWhenNoError,
27190
27195
  autoComplete: autocompleteValue,
27191
27196
  required: isRequired
27197
+ // Additional handler to detect autofilled values
27198
+ }, autocompleteValue && {
27199
+ onFocus: function onFocus(e) {
27200
+ if (!isFocused) {
27201
+ var _e$target;
27202
+ setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
27203
+ setIsFocused(true);
27204
+ }
27205
+ }
27192
27206
  }, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
27193
27207
  "aria-labelledby": createIdFromString(labelTextWhenNoError),
27194
27208
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
@@ -39263,46 +39277,69 @@ var fallbackValues$y = {
39263
39277
  var HiddenToggleSwitchBox = styled__default.input.withConfig({
39264
39278
  displayName: "ToggleSwitch__HiddenToggleSwitchBox",
39265
39279
  componentId: "sc-1t51u6v-0"
39266
- })(["opacity:0;position:absolute;cursor:", ";height:24px;width:50px;", ""], function (_ref) {
39280
+ })(["opacity:0;margin:0;position:absolute;cursor:", ";height:", ";width:", ";"], function (_ref) {
39267
39281
  var disabled = _ref.disabled;
39268
39282
  return disabled ? "auto" : "pointer";
39269
39283
  }, function (_ref2) {
39270
39284
  var isMobile = _ref2.isMobile;
39271
- return isMobile ? "transform: scale(0.75)" : "";
39285
+ return isMobile ? "22px" : "24px";
39286
+ }, function (_ref3) {
39287
+ var isMobile = _ref3.isMobile;
39288
+ return isMobile ? "40px" : "44px";
39272
39289
  });
39273
- var VisibleSwitchComponent = styled__default.label.withConfig({
39290
+ var VisibleSwitchComponent = styled__default.span.withConfig({
39274
39291
  displayName: "ToggleSwitch__VisibleSwitchComponent",
39275
39292
  componentId: "sc-1t51u6v-1"
39276
- })(["width:44px;height:24px;border-radius:12px;border:none;position:relative;box-sizing:border-box;cursor:", ";display:inline-block;&:hover{box-shadow:", ";}&:focus{box-shadow:0px 2px 5px 0px rgba(0,0,0,0.5);}", ""], function (_ref3) {
39277
- var disabled = _ref3.disabled;
39278
- return disabled ? "auto" : "pointer";
39279
- }, function (_ref4) {
39280
- var disabled = _ref4.disabled;
39281
- return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
39293
+ })(["width:", ";height:", ";border-radius:12px;border:none;position:relative;box-sizing:border-box;cursor:", ";display:inline-block;&:hover{box-shadow:", ";}&:focus{box-shadow:0px 2px 5px 0px rgba(0,0,0,0.5);}"], function (_ref4) {
39294
+ var isMobile = _ref4.isMobile;
39295
+ return isMobile ? "40px" : "44px";
39282
39296
  }, function (_ref5) {
39283
39297
  var isMobile = _ref5.isMobile;
39284
- return isMobile ? "transform: scale(0.75)" : "";
39298
+ return isMobile ? "22px" : "24px";
39299
+ }, function (_ref6) {
39300
+ var disabled = _ref6.disabled;
39301
+ return disabled ? "auto" : "pointer";
39302
+ }, function (_ref7) {
39303
+ var disabled = _ref7.disabled;
39304
+ return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
39285
39305
  });
39286
- var ToggleSwitchRingComponent = styled__default.div.withConfig({
39306
+ var ToggleSwitchRingComponent = styled__default.span.withConfig({
39287
39307
  displayName: "ToggleSwitch__ToggleSwitchRingComponent",
39288
39308
  componentId: "sc-1t51u6v-2"
39289
- })(["position:absolute;width:16px;height:16px;border:none;border-radius:50%;box-sizing:border-box;"]);
39290
- var ToggleSwitch = function ToggleSwitch(_ref6) {
39291
- var _ref6$isOn = _ref6.isOn,
39292
- isOn = _ref6$isOn === void 0 ? false : _ref6$isOn,
39293
- _ref6$onToggle = _ref6.onToggle,
39294
- onToggle = _ref6$onToggle === void 0 ? noop : _ref6$onToggle,
39295
- _ref6$disabled = _ref6.disabled,
39296
- disabled = _ref6$disabled === void 0 ? false : _ref6$disabled,
39297
- _ref6$name = _ref6.name,
39298
- name = _ref6$name === void 0 ? "" : _ref6$name,
39299
- _ref6$label = _ref6.label,
39300
- label = _ref6$label === void 0 ? null : _ref6$label,
39301
- _ref6$labelLeft = _ref6.labelLeft,
39302
- labelLeft = _ref6$labelLeft === void 0 ? false : _ref6$labelLeft,
39303
- themeValues = _ref6.themeValues,
39304
- isMobile = _ref6.isMobile,
39305
- dataQa = _ref6.dataQa;
39309
+ })(["position:absolute;width:", ";height:", ";border:none;border-radius:50%;box-sizing:border-box;"], function (_ref8) {
39310
+ var isMobile = _ref8.isMobile;
39311
+ return isMobile ? "14px" : "16px";
39312
+ }, function (_ref9) {
39313
+ var isMobile = _ref9.isMobile;
39314
+ return isMobile ? "14px" : "16px";
39315
+ });
39316
+ var ToggleSwitch = function ToggleSwitch(_ref10) {
39317
+ var _ref10$ariaDescribedB = _ref10.ariaDescribedBy,
39318
+ ariaDescribedBy = _ref10$ariaDescribedB === void 0 ? "" : _ref10$ariaDescribedB,
39319
+ _ref10$isOn = _ref10.isOn,
39320
+ isOn = _ref10$isOn === void 0 ? false : _ref10$isOn,
39321
+ _ref10$onToggle = _ref10.onToggle,
39322
+ onToggle = _ref10$onToggle === void 0 ? noop : _ref10$onToggle,
39323
+ _ref10$disabled = _ref10.disabled,
39324
+ disabled = _ref10$disabled === void 0 ? false : _ref10$disabled,
39325
+ _ref10$name = _ref10.name,
39326
+ name = _ref10$name === void 0 ? "toggle" : _ref10$name,
39327
+ _ref10$label = _ref10.label,
39328
+ label = _ref10$label === void 0 ? null : _ref10$label,
39329
+ _ref10$labelLeft = _ref10.labelLeft,
39330
+ labelLeft = _ref10$labelLeft === void 0 ? false : _ref10$labelLeft,
39331
+ _ref10$labelStyles = _ref10.labelStyles,
39332
+ labelStyles = _ref10$labelStyles === void 0 ? "" : _ref10$labelStyles,
39333
+ _ref10$labelAs = _ref10.labelAs,
39334
+ labelAs = _ref10$labelAs === void 0 ? "label" : _ref10$labelAs,
39335
+ themeValues = _ref10.themeValues,
39336
+ isMobile = _ref10.isMobile,
39337
+ dataQa = _ref10.dataQa,
39338
+ _ref10$minWidth = _ref10.minWidth,
39339
+ minWidth = _ref10$minWidth === void 0 ? "80px" : _ref10$minWidth,
39340
+ _ref10$extraStyles = _ref10.extraStyles,
39341
+ extraStyles = _ref10$extraStyles === void 0 ? "" : _ref10$extraStyles;
39342
+ var nameId = name.replace(/ /g, "-");
39306
39343
  var ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
39307
39344
  off: {
39308
39345
  backgroundColor: disabled ? themeValues.disabledBackground : themeValues.onBackground,
@@ -39359,12 +39396,14 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
39359
39396
  }
39360
39397
  };
39361
39398
  return /*#__PURE__*/React__default.createElement(Box, {
39362
- padding: "0",
39363
- extraStyles: labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles
39399
+ padding: "0.5rem",
39400
+ extraStyles: "\n margin: 0 0.5rem;\n ".concat(labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles).concat(extraStyles)
39364
39401
  }, /*#__PURE__*/React__default.createElement(Center, null, /*#__PURE__*/React__default.createElement(Cluster, {
39365
- justify: "stretch",
39402
+ justify: "space-between",
39366
39403
  align: "center",
39367
- overflow: "visible"
39404
+ overflow: "visible",
39405
+ childGap: "0",
39406
+ minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : isMobile ? "75px" : "84px"
39368
39407
  }, /*#__PURE__*/React__default.createElement(Cover, {
39369
39408
  minHeight: "100%",
39370
39409
  singleChild: true
@@ -39374,26 +39413,33 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
39374
39413
  extraStyles: "display: flex; align-items: center;",
39375
39414
  dataQa: dataQa
39376
39415
  }, /*#__PURE__*/React__default.createElement(HiddenToggleSwitchBox, {
39416
+ type: "checkbox",
39417
+ "aria-checked": isOn,
39377
39418
  "aria-label": name,
39419
+ "aria-labelledby": label ? "".concat(nameId, "-label") : null,
39420
+ "aria-describedby": ariaDescribedBy ? ariaDescribedBy : null,
39378
39421
  checked: isOn,
39379
39422
  onChange: disabled ? noop : onToggle,
39380
39423
  disabled: disabled,
39381
- id: "#toggle-".concat(name),
39424
+ id: "#".concat(nameId),
39382
39425
  isMobile: isMobile
39383
39426
  }), /*#__PURE__*/React__default.createElement(VisibleSwitch, {
39384
- name: name,
39385
- htmlFor: "#toggle-".concat(name),
39386
39427
  onClick: disabled ? noop : onToggle,
39387
39428
  onKeyDown: disabled ? noop : handleKeyDown,
39388
39429
  pose: isOn ? "on" : "off",
39389
39430
  tabIndex: disabled ? -1 : 0,
39390
39431
  disabled: disabled,
39432
+ isMobile: isMobile,
39433
+ tabindex: "0"
39434
+ }, /*#__PURE__*/React__default.createElement(ToggleSwitchRing, {
39391
39435
  isMobile: isMobile
39392
- }, /*#__PURE__*/React__default.createElement(ToggleSwitchRing, null)))), label && /*#__PURE__*/React__default.createElement(Heading$1, {
39393
- variant: "h4",
39394
- weight: FONT_WEIGHT_SEMIBOLD,
39395
- extraStyles: "margin: 0 0.5rem; position: relative; bottom: 1px; display: inline-block;",
39396
- color: CHARADE_GREY
39436
+ })))), label && /*#__PURE__*/React__default.createElement(Box, {
39437
+ as: labelAs,
39438
+ "aria-label": "".concat(name, ": ").concat(label),
39439
+ extraStyles: "\n font-weight: ".concat(FONT_WEIGHT_SEMIBOLD, ";\n color: ").concat(CHARADE_GREY, ";\n margin: 0 0 0 0.25rem; \n position: relative; \n bottom: 1px; \n display: inline-block; \n ").concat(labelStyles),
39440
+ id: "".concat(nameId, "-label"),
39441
+ htmlFor: labelAs === "label" ? nameId : null,
39442
+ padding: "0"
39397
39443
  }, label))));
39398
39444
  };
39399
39445
  var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$y);
@@ -48654,6 +48700,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
48654
48700
  },
48655
48701
  isNum: true,
48656
48702
  autocompleteValue: "cc-number",
48703
+ name: "cc-number",
48657
48704
  isRequired: true
48658
48705
  }), /*#__PURE__*/React__default.createElement(FormInputRow, {
48659
48706
  breakpoint: isMobile ? "1000rem" : "21rem",