@thecb/components 10.7.5 → 10.7.6
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 +55 -74
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +55 -74
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/form-layouts/FormInput.js +11 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +29 -57
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +1 -0
package/dist/index.esm.js
CHANGED
|
@@ -27098,6 +27098,10 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27098
27098
|
_useState2 = _slicedToArray(_useState, 2),
|
|
27099
27099
|
showPassword = _useState2[0],
|
|
27100
27100
|
setShowPassword = _useState2[1];
|
|
27101
|
+
var _useState3 = useState(false),
|
|
27102
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
27103
|
+
isFocused = _useState4[0],
|
|
27104
|
+
setIsFocused = _useState4[1];
|
|
27101
27105
|
var _useContext = useContext(ThemeContext),
|
|
27102
27106
|
isMobile = _useContext.isMobile;
|
|
27103
27107
|
var setValue = function setValue(value) {
|
|
@@ -27111,6 +27115,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27111
27115
|
if (isRequired && value === "") {
|
|
27112
27116
|
setValue("");
|
|
27113
27117
|
}
|
|
27118
|
+
setIsFocused(false);
|
|
27114
27119
|
};
|
|
27115
27120
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
27116
27121
|
childGap: "0.25rem"
|
|
@@ -27181,6 +27186,15 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27181
27186
|
"data-qa": dataQa || labelTextWhenNoError,
|
|
27182
27187
|
autoComplete: autocompleteValue,
|
|
27183
27188
|
required: isRequired
|
|
27189
|
+
// Additional handler to detect autofilled values
|
|
27190
|
+
}, autocompleteValue && {
|
|
27191
|
+
onFocus: function onFocus(e) {
|
|
27192
|
+
if (!isFocused) {
|
|
27193
|
+
var _e$target;
|
|
27194
|
+
setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
|
|
27195
|
+
setIsFocused(true);
|
|
27196
|
+
}
|
|
27197
|
+
}
|
|
27184
27198
|
}, props)) : /*#__PURE__*/React.createElement(InputField, _extends({
|
|
27185
27199
|
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
27186
27200
|
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
@@ -39255,71 +39269,46 @@ var fallbackValues$y = {
|
|
|
39255
39269
|
var HiddenToggleSwitchBox = styled.input.withConfig({
|
|
39256
39270
|
displayName: "ToggleSwitch__HiddenToggleSwitchBox",
|
|
39257
39271
|
componentId: "sc-1t51u6v-0"
|
|
39258
|
-
})(["opacity:0;
|
|
39272
|
+
})(["opacity:0;position:absolute;cursor:", ";height:24px;width:50px;", ""], function (_ref) {
|
|
39259
39273
|
var disabled = _ref.disabled;
|
|
39260
39274
|
return disabled ? "auto" : "pointer";
|
|
39261
39275
|
}, function (_ref2) {
|
|
39262
39276
|
var isMobile = _ref2.isMobile;
|
|
39263
|
-
return isMobile ? "
|
|
39264
|
-
}, function (_ref3) {
|
|
39265
|
-
var isMobile = _ref3.isMobile;
|
|
39266
|
-
return isMobile ? "40px" : "44px";
|
|
39277
|
+
return isMobile ? "transform: scale(0.75)" : "";
|
|
39267
39278
|
});
|
|
39268
|
-
var VisibleSwitchComponent = styled.
|
|
39279
|
+
var VisibleSwitchComponent = styled.label.withConfig({
|
|
39269
39280
|
displayName: "ToggleSwitch__VisibleSwitchComponent",
|
|
39270
39281
|
componentId: "sc-1t51u6v-1"
|
|
39271
|
-
})(["width:
|
|
39272
|
-
var
|
|
39273
|
-
return isMobile ? "40px" : "44px";
|
|
39274
|
-
}, function (_ref5) {
|
|
39275
|
-
var isMobile = _ref5.isMobile;
|
|
39276
|
-
return isMobile ? "22px" : "24px";
|
|
39277
|
-
}, function (_ref6) {
|
|
39278
|
-
var disabled = _ref6.disabled;
|
|
39282
|
+
})(["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) {
|
|
39283
|
+
var disabled = _ref3.disabled;
|
|
39279
39284
|
return disabled ? "auto" : "pointer";
|
|
39280
|
-
}, function (
|
|
39281
|
-
var disabled =
|
|
39285
|
+
}, function (_ref4) {
|
|
39286
|
+
var disabled = _ref4.disabled;
|
|
39282
39287
|
return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
|
|
39288
|
+
}, function (_ref5) {
|
|
39289
|
+
var isMobile = _ref5.isMobile;
|
|
39290
|
+
return isMobile ? "transform: scale(0.75)" : "";
|
|
39283
39291
|
});
|
|
39284
|
-
var ToggleSwitchRingComponent = styled.
|
|
39292
|
+
var ToggleSwitchRingComponent = styled.div.withConfig({
|
|
39285
39293
|
displayName: "ToggleSwitch__ToggleSwitchRingComponent",
|
|
39286
39294
|
componentId: "sc-1t51u6v-2"
|
|
39287
|
-
})(["position:absolute;width:
|
|
39288
|
-
|
|
39289
|
-
|
|
39290
|
-
|
|
39291
|
-
|
|
39292
|
-
|
|
39293
|
-
|
|
39294
|
-
|
|
39295
|
-
|
|
39296
|
-
|
|
39297
|
-
|
|
39298
|
-
|
|
39299
|
-
|
|
39300
|
-
|
|
39301
|
-
|
|
39302
|
-
|
|
39303
|
-
|
|
39304
|
-
name = _ref10$name === void 0 ? "toggle" : _ref10$name,
|
|
39305
|
-
_ref10$label = _ref10.label,
|
|
39306
|
-
label = _ref10$label === void 0 ? null : _ref10$label,
|
|
39307
|
-
_ref10$labelLeft = _ref10.labelLeft,
|
|
39308
|
-
labelLeft = _ref10$labelLeft === void 0 ? false : _ref10$labelLeft,
|
|
39309
|
-
_ref10$labelStyles = _ref10.labelStyles,
|
|
39310
|
-
labelStyles = _ref10$labelStyles === void 0 ? "" : _ref10$labelStyles,
|
|
39311
|
-
_ref10$labelAs = _ref10.labelAs,
|
|
39312
|
-
labelAs = _ref10$labelAs === void 0 ? "h4" : _ref10$labelAs,
|
|
39313
|
-
_ref10$srOnlyLabel = _ref10.srOnlyLabel,
|
|
39314
|
-
srOnlyLabel = _ref10$srOnlyLabel === void 0 ? "" : _ref10$srOnlyLabel,
|
|
39315
|
-
themeValues = _ref10.themeValues,
|
|
39316
|
-
isMobile = _ref10.isMobile,
|
|
39317
|
-
dataQa = _ref10.dataQa,
|
|
39318
|
-
_ref10$minWidth = _ref10.minWidth,
|
|
39319
|
-
minWidth = _ref10$minWidth === void 0 ? "80px" : _ref10$minWidth,
|
|
39320
|
-
_ref10$extraStyles = _ref10.extraStyles,
|
|
39321
|
-
extraStyles = _ref10$extraStyles === void 0 ? "" : _ref10$extraStyles;
|
|
39322
|
-
var nameId = name.replace(/ /g, "-");
|
|
39295
|
+
})(["position:absolute;width:16px;height:16px;border:none;border-radius:50%;box-sizing:border-box;"]);
|
|
39296
|
+
var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
39297
|
+
var _ref6$isOn = _ref6.isOn,
|
|
39298
|
+
isOn = _ref6$isOn === void 0 ? false : _ref6$isOn,
|
|
39299
|
+
_ref6$onToggle = _ref6.onToggle,
|
|
39300
|
+
onToggle = _ref6$onToggle === void 0 ? noop : _ref6$onToggle,
|
|
39301
|
+
_ref6$disabled = _ref6.disabled,
|
|
39302
|
+
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled,
|
|
39303
|
+
_ref6$name = _ref6.name,
|
|
39304
|
+
name = _ref6$name === void 0 ? "" : _ref6$name,
|
|
39305
|
+
_ref6$label = _ref6.label,
|
|
39306
|
+
label = _ref6$label === void 0 ? null : _ref6$label,
|
|
39307
|
+
_ref6$labelLeft = _ref6.labelLeft,
|
|
39308
|
+
labelLeft = _ref6$labelLeft === void 0 ? false : _ref6$labelLeft,
|
|
39309
|
+
themeValues = _ref6.themeValues,
|
|
39310
|
+
isMobile = _ref6.isMobile,
|
|
39311
|
+
dataQa = _ref6.dataQa;
|
|
39323
39312
|
var ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
|
|
39324
39313
|
off: {
|
|
39325
39314
|
backgroundColor: disabled ? themeValues.disabledBackground : themeValues.onBackground,
|
|
@@ -39377,13 +39366,11 @@ var ToggleSwitch = function ToggleSwitch(_ref10) {
|
|
|
39377
39366
|
};
|
|
39378
39367
|
return /*#__PURE__*/React.createElement(Box, {
|
|
39379
39368
|
padding: "0",
|
|
39380
|
-
extraStyles:
|
|
39369
|
+
extraStyles: labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles
|
|
39381
39370
|
}, /*#__PURE__*/React.createElement(Center, null, /*#__PURE__*/React.createElement(Cluster, {
|
|
39382
|
-
justify: "
|
|
39371
|
+
justify: "stretch",
|
|
39383
39372
|
align: "center",
|
|
39384
|
-
overflow: "visible"
|
|
39385
|
-
childGap: "0",
|
|
39386
|
-
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : isMobile ? "75px" : "84px"
|
|
39373
|
+
overflow: "visible"
|
|
39387
39374
|
}, /*#__PURE__*/React.createElement(Cover, {
|
|
39388
39375
|
minHeight: "100%",
|
|
39389
39376
|
singleChild: true
|
|
@@ -39393,34 +39380,27 @@ var ToggleSwitch = function ToggleSwitch(_ref10) {
|
|
|
39393
39380
|
extraStyles: "display: flex; align-items: center;",
|
|
39394
39381
|
dataQa: dataQa
|
|
39395
39382
|
}, /*#__PURE__*/React.createElement(HiddenToggleSwitchBox, {
|
|
39396
|
-
type: "checkbox",
|
|
39397
|
-
"aria-checked": isOn,
|
|
39398
39383
|
"aria-label": name,
|
|
39399
|
-
"aria-labelledby": label ? "".concat(nameId, "-label") : null,
|
|
39400
|
-
"aria-describedby": ariaDescribedBy ? ariaDescribedBy : null,
|
|
39401
39384
|
checked: isOn,
|
|
39402
39385
|
onChange: disabled ? noop : onToggle,
|
|
39403
39386
|
disabled: disabled,
|
|
39404
|
-
id: "#".concat(
|
|
39387
|
+
id: "#toggle-".concat(name),
|
|
39405
39388
|
isMobile: isMobile
|
|
39406
39389
|
}), /*#__PURE__*/React.createElement(VisibleSwitch, {
|
|
39390
|
+
name: name,
|
|
39391
|
+
htmlFor: "#toggle-".concat(name),
|
|
39407
39392
|
onClick: disabled ? noop : onToggle,
|
|
39408
39393
|
onKeyDown: disabled ? noop : handleKeyDown,
|
|
39409
39394
|
pose: isOn ? "on" : "off",
|
|
39410
39395
|
tabIndex: disabled ? -1 : 0,
|
|
39411
39396
|
disabled: disabled,
|
|
39412
39397
|
isMobile: isMobile
|
|
39413
|
-
}, /*#__PURE__*/React.createElement(ToggleSwitchRing, {
|
|
39414
|
-
|
|
39415
|
-
|
|
39416
|
-
|
|
39417
|
-
|
|
39418
|
-
|
|
39419
|
-
htmlFor: labelAs === "label" ? nameId : null,
|
|
39420
|
-
padding: "0"
|
|
39421
|
-
}, srOnlyLabel && /*#__PURE__*/React.createElement("span", {
|
|
39422
|
-
style: SCREEN_READER_ONLY
|
|
39423
|
-
}, srOnlyLabel), label))));
|
|
39398
|
+
}, /*#__PURE__*/React.createElement(ToggleSwitchRing, null)))), label && /*#__PURE__*/React.createElement(Heading$1, {
|
|
39399
|
+
variant: "h4",
|
|
39400
|
+
weight: FONT_WEIGHT_SEMIBOLD,
|
|
39401
|
+
extraStyles: "margin: 0 0.5rem; position: relative; bottom: 1px; display: inline-block;",
|
|
39402
|
+
color: CHARADE_GREY
|
|
39403
|
+
}, label))));
|
|
39424
39404
|
};
|
|
39425
39405
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$y);
|
|
39426
39406
|
|
|
@@ -48680,6 +48660,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48680
48660
|
},
|
|
48681
48661
|
isNum: true,
|
|
48682
48662
|
autocompleteValue: "cc-number",
|
|
48663
|
+
name: "cc-number",
|
|
48683
48664
|
isRequired: true
|
|
48684
48665
|
}), /*#__PURE__*/React.createElement(FormInputRow, {
|
|
48685
48666
|
breakpoint: isMobile ? "1000rem" : "21rem",
|