@thecb/components 10.7.4-beta.0 → 10.7.5-beta.0
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 +84 -70
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +84 -70
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/form-layouts/FormInput.js +11 -25
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +57 -29
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -27041,35 +27041,20 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27041
27041
|
_useState2 = _slicedToArray(_useState, 2),
|
|
27042
27042
|
showPassword = _useState2[0],
|
|
27043
27043
|
setShowPassword = _useState2[1];
|
|
27044
|
-
var _useState3 = React.useState((field === null || field === void 0 ? void 0 : field.rawValue) || ""),
|
|
27045
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
27046
|
-
initialValue = _useState4[0],
|
|
27047
|
-
setInitialValue = _useState4[1];
|
|
27048
27044
|
var _useContext = React.useContext(styled.ThemeContext),
|
|
27049
27045
|
isMobile = _useContext.isMobile;
|
|
27050
|
-
var setValue = function setValue(
|
|
27051
|
-
if (
|
|
27052
|
-
|
|
27046
|
+
var setValue = function setValue(value) {
|
|
27047
|
+
if (removeFromValue !== undefined) {
|
|
27048
|
+
return fieldActions.set(value.replace(removeFromValue, ""));
|
|
27053
27049
|
}
|
|
27050
|
+
return fieldActions.set(value);
|
|
27054
27051
|
};
|
|
27055
|
-
var
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
|
|
27059
|
-
} else {
|
|
27060
|
-
fieldActions.set(currentValue);
|
|
27061
|
-
}
|
|
27052
|
+
var handleOnBlur = function handleOnBlur(value) {
|
|
27053
|
+
// Sets the empty value to trigger a validation error if it's required.
|
|
27054
|
+
if (isRequired && value === "") {
|
|
27055
|
+
setValue("");
|
|
27062
27056
|
}
|
|
27063
27057
|
};
|
|
27064
|
-
React.useEffect(function () {
|
|
27065
|
-
if (initialValue) {
|
|
27066
|
-
if (removeFromValue !== undefined) {
|
|
27067
|
-
fieldActions.set(initialValue.replace(removeFromValue, ""));
|
|
27068
|
-
} else {
|
|
27069
|
-
fieldActions.set(initialValue);
|
|
27070
|
-
}
|
|
27071
|
-
}
|
|
27072
|
-
}, [initialValue]);
|
|
27073
27058
|
return /*#__PURE__*/React__default.createElement(Stack, {
|
|
27074
27059
|
childGap: "0.25rem"
|
|
27075
27060
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
@@ -27120,15 +27105,11 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27120
27105
|
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
27121
27106
|
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
27122
27107
|
"aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
|
|
27123
|
-
onFocus: function onFocus(e) {
|
|
27124
|
-
var _e$target;
|
|
27125
|
-
return setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
|
|
27126
|
-
},
|
|
27127
27108
|
onChange: function onChange(value) {
|
|
27128
27109
|
return setValue(value);
|
|
27129
27110
|
},
|
|
27130
27111
|
onBlur: function onBlur(e) {
|
|
27131
|
-
return
|
|
27112
|
+
return handleOnBlur(e.target.value);
|
|
27132
27113
|
},
|
|
27133
27114
|
type: type,
|
|
27134
27115
|
value: field.rawValue,
|
|
@@ -27151,7 +27132,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27151
27132
|
return setValue(e.target.value);
|
|
27152
27133
|
},
|
|
27153
27134
|
onBlur: function onBlur(e) {
|
|
27154
|
-
return
|
|
27135
|
+
return handleOnBlur(e.target.value);
|
|
27155
27136
|
},
|
|
27156
27137
|
type: type === "password" && showPassword ? "text" : type,
|
|
27157
27138
|
value: field.rawValue,
|
|
@@ -39217,46 +39198,71 @@ var fallbackValues$y = {
|
|
|
39217
39198
|
var HiddenToggleSwitchBox = styled__default.input.withConfig({
|
|
39218
39199
|
displayName: "ToggleSwitch__HiddenToggleSwitchBox",
|
|
39219
39200
|
componentId: "sc-1t51u6v-0"
|
|
39220
|
-
})(["opacity:0;position:absolute;cursor:", ";height:
|
|
39201
|
+
})(["opacity:0;margin:0;position:absolute;cursor:", ";height:", ";width:", ";"], function (_ref) {
|
|
39221
39202
|
var disabled = _ref.disabled;
|
|
39222
39203
|
return disabled ? "auto" : "pointer";
|
|
39223
39204
|
}, function (_ref2) {
|
|
39224
39205
|
var isMobile = _ref2.isMobile;
|
|
39225
|
-
return isMobile ? "
|
|
39206
|
+
return isMobile ? "22px" : "24px";
|
|
39207
|
+
}, function (_ref3) {
|
|
39208
|
+
var isMobile = _ref3.isMobile;
|
|
39209
|
+
return isMobile ? "40px" : "44px";
|
|
39226
39210
|
});
|
|
39227
|
-
var VisibleSwitchComponent = styled__default.
|
|
39211
|
+
var VisibleSwitchComponent = styled__default.span.withConfig({
|
|
39228
39212
|
displayName: "ToggleSwitch__VisibleSwitchComponent",
|
|
39229
39213
|
componentId: "sc-1t51u6v-1"
|
|
39230
|
-
})(["width:
|
|
39231
|
-
var
|
|
39232
|
-
return
|
|
39233
|
-
}, function (_ref4) {
|
|
39234
|
-
var disabled = _ref4.disabled;
|
|
39235
|
-
return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
|
|
39214
|
+
})(["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) {
|
|
39215
|
+
var isMobile = _ref4.isMobile;
|
|
39216
|
+
return isMobile ? "40px" : "44px";
|
|
39236
39217
|
}, function (_ref5) {
|
|
39237
39218
|
var isMobile = _ref5.isMobile;
|
|
39238
|
-
return isMobile ? "
|
|
39219
|
+
return isMobile ? "22px" : "24px";
|
|
39220
|
+
}, function (_ref6) {
|
|
39221
|
+
var disabled = _ref6.disabled;
|
|
39222
|
+
return disabled ? "auto" : "pointer";
|
|
39223
|
+
}, function (_ref7) {
|
|
39224
|
+
var disabled = _ref7.disabled;
|
|
39225
|
+
return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
|
|
39239
39226
|
});
|
|
39240
|
-
var ToggleSwitchRingComponent = styled__default.
|
|
39227
|
+
var ToggleSwitchRingComponent = styled__default.span.withConfig({
|
|
39241
39228
|
displayName: "ToggleSwitch__ToggleSwitchRingComponent",
|
|
39242
39229
|
componentId: "sc-1t51u6v-2"
|
|
39243
|
-
})(["position:absolute;width:
|
|
39244
|
-
var
|
|
39245
|
-
|
|
39246
|
-
|
|
39247
|
-
|
|
39248
|
-
|
|
39249
|
-
|
|
39250
|
-
|
|
39251
|
-
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
|
|
39255
|
-
|
|
39256
|
-
|
|
39257
|
-
|
|
39258
|
-
|
|
39259
|
-
|
|
39230
|
+
})(["position:absolute;width:", ";height:", ";border:none;border-radius:50%;box-sizing:border-box;"], function (_ref8) {
|
|
39231
|
+
var isMobile = _ref8.isMobile;
|
|
39232
|
+
return isMobile ? "14px" : "16px";
|
|
39233
|
+
}, function (_ref9) {
|
|
39234
|
+
var isMobile = _ref9.isMobile;
|
|
39235
|
+
return isMobile ? "14px" : "16px";
|
|
39236
|
+
});
|
|
39237
|
+
var ToggleSwitch = function ToggleSwitch(_ref10) {
|
|
39238
|
+
var _ref10$ariaDescribedB = _ref10.ariaDescribedBy,
|
|
39239
|
+
ariaDescribedBy = _ref10$ariaDescribedB === void 0 ? "" : _ref10$ariaDescribedB,
|
|
39240
|
+
_ref10$isOn = _ref10.isOn,
|
|
39241
|
+
isOn = _ref10$isOn === void 0 ? false : _ref10$isOn,
|
|
39242
|
+
_ref10$onToggle = _ref10.onToggle,
|
|
39243
|
+
onToggle = _ref10$onToggle === void 0 ? noop : _ref10$onToggle,
|
|
39244
|
+
_ref10$disabled = _ref10.disabled,
|
|
39245
|
+
disabled = _ref10$disabled === void 0 ? false : _ref10$disabled,
|
|
39246
|
+
_ref10$name = _ref10.name,
|
|
39247
|
+
name = _ref10$name === void 0 ? "toggle" : _ref10$name,
|
|
39248
|
+
_ref10$label = _ref10.label,
|
|
39249
|
+
label = _ref10$label === void 0 ? null : _ref10$label,
|
|
39250
|
+
_ref10$labelLeft = _ref10.labelLeft,
|
|
39251
|
+
labelLeft = _ref10$labelLeft === void 0 ? false : _ref10$labelLeft,
|
|
39252
|
+
_ref10$labelStyles = _ref10.labelStyles,
|
|
39253
|
+
labelStyles = _ref10$labelStyles === void 0 ? "" : _ref10$labelStyles,
|
|
39254
|
+
_ref10$labelAs = _ref10.labelAs,
|
|
39255
|
+
labelAs = _ref10$labelAs === void 0 ? "h4" : _ref10$labelAs,
|
|
39256
|
+
_ref10$srOnlyLabel = _ref10.srOnlyLabel,
|
|
39257
|
+
srOnlyLabel = _ref10$srOnlyLabel === void 0 ? "" : _ref10$srOnlyLabel,
|
|
39258
|
+
themeValues = _ref10.themeValues,
|
|
39259
|
+
isMobile = _ref10.isMobile,
|
|
39260
|
+
dataQa = _ref10.dataQa,
|
|
39261
|
+
_ref10$minWidth = _ref10.minWidth,
|
|
39262
|
+
minWidth = _ref10$minWidth === void 0 ? "80px" : _ref10$minWidth,
|
|
39263
|
+
_ref10$extraStyles = _ref10.extraStyles,
|
|
39264
|
+
extraStyles = _ref10$extraStyles === void 0 ? "" : _ref10$extraStyles;
|
|
39265
|
+
var nameId = name.replace(/ /g, "-");
|
|
39260
39266
|
var ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
|
|
39261
39267
|
off: {
|
|
39262
39268
|
backgroundColor: disabled ? themeValues.disabledBackground : themeValues.onBackground,
|
|
@@ -39314,11 +39320,13 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
39314
39320
|
};
|
|
39315
39321
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
39316
39322
|
padding: "0",
|
|
39317
|
-
extraStyles: labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles
|
|
39323
|
+
extraStyles: "\n margin: 0 0.5rem;\n ".concat(labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles).concat(extraStyles)
|
|
39318
39324
|
}, /*#__PURE__*/React__default.createElement(Center, null, /*#__PURE__*/React__default.createElement(Cluster, {
|
|
39319
|
-
justify: "
|
|
39325
|
+
justify: "space-between",
|
|
39320
39326
|
align: "center",
|
|
39321
|
-
overflow: "visible"
|
|
39327
|
+
overflow: "visible",
|
|
39328
|
+
childGap: "0",
|
|
39329
|
+
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : isMobile ? "75px" : "84px"
|
|
39322
39330
|
}, /*#__PURE__*/React__default.createElement(Cover, {
|
|
39323
39331
|
minHeight: "100%",
|
|
39324
39332
|
singleChild: true
|
|
@@ -39328,27 +39336,34 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
39328
39336
|
extraStyles: "display: flex; align-items: center;",
|
|
39329
39337
|
dataQa: dataQa
|
|
39330
39338
|
}, /*#__PURE__*/React__default.createElement(HiddenToggleSwitchBox, {
|
|
39339
|
+
type: "checkbox",
|
|
39340
|
+
"aria-checked": isOn,
|
|
39331
39341
|
"aria-label": name,
|
|
39342
|
+
"aria-labelledby": label ? "".concat(nameId, "-label") : null,
|
|
39343
|
+
"aria-describedby": ariaDescribedBy ? ariaDescribedBy : null,
|
|
39332
39344
|
checked: isOn,
|
|
39333
39345
|
onChange: disabled ? noop : onToggle,
|
|
39334
39346
|
disabled: disabled,
|
|
39335
|
-
id: "#
|
|
39347
|
+
id: "#".concat(nameId),
|
|
39336
39348
|
isMobile: isMobile
|
|
39337
39349
|
}), /*#__PURE__*/React__default.createElement(VisibleSwitch, {
|
|
39338
|
-
name: name,
|
|
39339
|
-
htmlFor: "#toggle-".concat(name),
|
|
39340
39350
|
onClick: disabled ? noop : onToggle,
|
|
39341
39351
|
onKeyDown: disabled ? noop : handleKeyDown,
|
|
39342
39352
|
pose: isOn ? "on" : "off",
|
|
39343
39353
|
tabIndex: disabled ? -1 : 0,
|
|
39344
39354
|
disabled: disabled,
|
|
39345
39355
|
isMobile: isMobile
|
|
39346
|
-
}, /*#__PURE__*/React__default.createElement(ToggleSwitchRing,
|
|
39347
|
-
|
|
39348
|
-
|
|
39349
|
-
|
|
39350
|
-
color: CHARADE_GREY
|
|
39351
|
-
|
|
39356
|
+
}, /*#__PURE__*/React__default.createElement(ToggleSwitchRing, {
|
|
39357
|
+
isMobile: isMobile
|
|
39358
|
+
})))), label && /*#__PURE__*/React__default.createElement(Box, {
|
|
39359
|
+
as: labelAs,
|
|
39360
|
+
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; display: \n inline-block; \n ").concat(labelStyles),
|
|
39361
|
+
id: "".concat(nameId, "-label"),
|
|
39362
|
+
htmlFor: labelAs === "label" ? nameId : null,
|
|
39363
|
+
padding: "0"
|
|
39364
|
+
}, srOnlyLabel && /*#__PURE__*/React__default.createElement("span", {
|
|
39365
|
+
style: SCREEN_READER_ONLY
|
|
39366
|
+
}, srOnlyLabel), label))));
|
|
39352
39367
|
};
|
|
39353
39368
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$y);
|
|
39354
39369
|
|
|
@@ -48608,7 +48623,6 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48608
48623
|
},
|
|
48609
48624
|
isNum: true,
|
|
48610
48625
|
autocompleteValue: "cc-number",
|
|
48611
|
-
name: "cc-number",
|
|
48612
48626
|
isRequired: true
|
|
48613
48627
|
}), /*#__PURE__*/React__default.createElement(FormInputRow, {
|
|
48614
48628
|
breakpoint: isMobile ? "1000rem" : "21rem",
|