@thecb/components 10.7.3 → 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 +74 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +74 -40
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +57 -29
package/dist/index.esm.js
CHANGED
|
@@ -39190,46 +39190,71 @@ var fallbackValues$y = {
|
|
|
39190
39190
|
var HiddenToggleSwitchBox = styled.input.withConfig({
|
|
39191
39191
|
displayName: "ToggleSwitch__HiddenToggleSwitchBox",
|
|
39192
39192
|
componentId: "sc-1t51u6v-0"
|
|
39193
|
-
})(["opacity:0;position:absolute;cursor:", ";height:
|
|
39193
|
+
})(["opacity:0;margin:0;position:absolute;cursor:", ";height:", ";width:", ";"], function (_ref) {
|
|
39194
39194
|
var disabled = _ref.disabled;
|
|
39195
39195
|
return disabled ? "auto" : "pointer";
|
|
39196
39196
|
}, function (_ref2) {
|
|
39197
39197
|
var isMobile = _ref2.isMobile;
|
|
39198
|
-
return isMobile ? "
|
|
39198
|
+
return isMobile ? "22px" : "24px";
|
|
39199
|
+
}, function (_ref3) {
|
|
39200
|
+
var isMobile = _ref3.isMobile;
|
|
39201
|
+
return isMobile ? "40px" : "44px";
|
|
39199
39202
|
});
|
|
39200
|
-
var VisibleSwitchComponent = styled.
|
|
39203
|
+
var VisibleSwitchComponent = styled.span.withConfig({
|
|
39201
39204
|
displayName: "ToggleSwitch__VisibleSwitchComponent",
|
|
39202
39205
|
componentId: "sc-1t51u6v-1"
|
|
39203
|
-
})(["width:
|
|
39204
|
-
var
|
|
39205
|
-
return
|
|
39206
|
-
}, function (_ref4) {
|
|
39207
|
-
var disabled = _ref4.disabled;
|
|
39208
|
-
return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
|
|
39206
|
+
})(["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) {
|
|
39207
|
+
var isMobile = _ref4.isMobile;
|
|
39208
|
+
return isMobile ? "40px" : "44px";
|
|
39209
39209
|
}, function (_ref5) {
|
|
39210
39210
|
var isMobile = _ref5.isMobile;
|
|
39211
|
-
return isMobile ? "
|
|
39211
|
+
return isMobile ? "22px" : "24px";
|
|
39212
|
+
}, function (_ref6) {
|
|
39213
|
+
var disabled = _ref6.disabled;
|
|
39214
|
+
return disabled ? "auto" : "pointer";
|
|
39215
|
+
}, function (_ref7) {
|
|
39216
|
+
var disabled = _ref7.disabled;
|
|
39217
|
+
return disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important";
|
|
39212
39218
|
});
|
|
39213
|
-
var ToggleSwitchRingComponent = styled.
|
|
39219
|
+
var ToggleSwitchRingComponent = styled.span.withConfig({
|
|
39214
39220
|
displayName: "ToggleSwitch__ToggleSwitchRingComponent",
|
|
39215
39221
|
componentId: "sc-1t51u6v-2"
|
|
39216
|
-
})(["position:absolute;width:
|
|
39217
|
-
var
|
|
39218
|
-
|
|
39219
|
-
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39225
|
-
|
|
39226
|
-
|
|
39227
|
-
|
|
39228
|
-
|
|
39229
|
-
|
|
39230
|
-
|
|
39231
|
-
|
|
39232
|
-
|
|
39222
|
+
})(["position:absolute;width:", ";height:", ";border:none;border-radius:50%;box-sizing:border-box;"], function (_ref8) {
|
|
39223
|
+
var isMobile = _ref8.isMobile;
|
|
39224
|
+
return isMobile ? "14px" : "16px";
|
|
39225
|
+
}, function (_ref9) {
|
|
39226
|
+
var isMobile = _ref9.isMobile;
|
|
39227
|
+
return isMobile ? "14px" : "16px";
|
|
39228
|
+
});
|
|
39229
|
+
var ToggleSwitch = function ToggleSwitch(_ref10) {
|
|
39230
|
+
var _ref10$ariaDescribedB = _ref10.ariaDescribedBy,
|
|
39231
|
+
ariaDescribedBy = _ref10$ariaDescribedB === void 0 ? "" : _ref10$ariaDescribedB,
|
|
39232
|
+
_ref10$isOn = _ref10.isOn,
|
|
39233
|
+
isOn = _ref10$isOn === void 0 ? false : _ref10$isOn,
|
|
39234
|
+
_ref10$onToggle = _ref10.onToggle,
|
|
39235
|
+
onToggle = _ref10$onToggle === void 0 ? noop : _ref10$onToggle,
|
|
39236
|
+
_ref10$disabled = _ref10.disabled,
|
|
39237
|
+
disabled = _ref10$disabled === void 0 ? false : _ref10$disabled,
|
|
39238
|
+
_ref10$name = _ref10.name,
|
|
39239
|
+
name = _ref10$name === void 0 ? "toggle" : _ref10$name,
|
|
39240
|
+
_ref10$label = _ref10.label,
|
|
39241
|
+
label = _ref10$label === void 0 ? null : _ref10$label,
|
|
39242
|
+
_ref10$labelLeft = _ref10.labelLeft,
|
|
39243
|
+
labelLeft = _ref10$labelLeft === void 0 ? false : _ref10$labelLeft,
|
|
39244
|
+
_ref10$labelStyles = _ref10.labelStyles,
|
|
39245
|
+
labelStyles = _ref10$labelStyles === void 0 ? "" : _ref10$labelStyles,
|
|
39246
|
+
_ref10$labelAs = _ref10.labelAs,
|
|
39247
|
+
labelAs = _ref10$labelAs === void 0 ? "h4" : _ref10$labelAs,
|
|
39248
|
+
_ref10$srOnlyLabel = _ref10.srOnlyLabel,
|
|
39249
|
+
srOnlyLabel = _ref10$srOnlyLabel === void 0 ? "" : _ref10$srOnlyLabel,
|
|
39250
|
+
themeValues = _ref10.themeValues,
|
|
39251
|
+
isMobile = _ref10.isMobile,
|
|
39252
|
+
dataQa = _ref10.dataQa,
|
|
39253
|
+
_ref10$minWidth = _ref10.minWidth,
|
|
39254
|
+
minWidth = _ref10$minWidth === void 0 ? "80px" : _ref10$minWidth,
|
|
39255
|
+
_ref10$extraStyles = _ref10.extraStyles,
|
|
39256
|
+
extraStyles = _ref10$extraStyles === void 0 ? "" : _ref10$extraStyles;
|
|
39257
|
+
var nameId = name.replace(/ /g, "-");
|
|
39233
39258
|
var ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
|
|
39234
39259
|
off: {
|
|
39235
39260
|
backgroundColor: disabled ? themeValues.disabledBackground : themeValues.onBackground,
|
|
@@ -39287,11 +39312,13 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
39287
39312
|
};
|
|
39288
39313
|
return /*#__PURE__*/React.createElement(Box, {
|
|
39289
39314
|
padding: "0",
|
|
39290
|
-
extraStyles: labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles
|
|
39315
|
+
extraStyles: "\n margin: 0 0.5rem;\n ".concat(labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles).concat(extraStyles)
|
|
39291
39316
|
}, /*#__PURE__*/React.createElement(Center, null, /*#__PURE__*/React.createElement(Cluster, {
|
|
39292
|
-
justify: "
|
|
39317
|
+
justify: "space-between",
|
|
39293
39318
|
align: "center",
|
|
39294
|
-
overflow: "visible"
|
|
39319
|
+
overflow: "visible",
|
|
39320
|
+
childGap: "0",
|
|
39321
|
+
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : isMobile ? "75px" : "84px"
|
|
39295
39322
|
}, /*#__PURE__*/React.createElement(Cover, {
|
|
39296
39323
|
minHeight: "100%",
|
|
39297
39324
|
singleChild: true
|
|
@@ -39301,27 +39328,34 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
39301
39328
|
extraStyles: "display: flex; align-items: center;",
|
|
39302
39329
|
dataQa: dataQa
|
|
39303
39330
|
}, /*#__PURE__*/React.createElement(HiddenToggleSwitchBox, {
|
|
39331
|
+
type: "checkbox",
|
|
39332
|
+
"aria-checked": isOn,
|
|
39304
39333
|
"aria-label": name,
|
|
39334
|
+
"aria-labelledby": label ? "".concat(nameId, "-label") : null,
|
|
39335
|
+
"aria-describedby": ariaDescribedBy ? ariaDescribedBy : null,
|
|
39305
39336
|
checked: isOn,
|
|
39306
39337
|
onChange: disabled ? noop : onToggle,
|
|
39307
39338
|
disabled: disabled,
|
|
39308
|
-
id: "#
|
|
39339
|
+
id: "#".concat(nameId),
|
|
39309
39340
|
isMobile: isMobile
|
|
39310
39341
|
}), /*#__PURE__*/React.createElement(VisibleSwitch, {
|
|
39311
|
-
name: name,
|
|
39312
|
-
htmlFor: "#toggle-".concat(name),
|
|
39313
39342
|
onClick: disabled ? noop : onToggle,
|
|
39314
39343
|
onKeyDown: disabled ? noop : handleKeyDown,
|
|
39315
39344
|
pose: isOn ? "on" : "off",
|
|
39316
39345
|
tabIndex: disabled ? -1 : 0,
|
|
39317
39346
|
disabled: disabled,
|
|
39318
39347
|
isMobile: isMobile
|
|
39319
|
-
}, /*#__PURE__*/React.createElement(ToggleSwitchRing,
|
|
39320
|
-
|
|
39321
|
-
|
|
39322
|
-
|
|
39323
|
-
color: CHARADE_GREY
|
|
39324
|
-
|
|
39348
|
+
}, /*#__PURE__*/React.createElement(ToggleSwitchRing, {
|
|
39349
|
+
isMobile: isMobile
|
|
39350
|
+
})))), label && /*#__PURE__*/React.createElement(Box, {
|
|
39351
|
+
as: labelAs,
|
|
39352
|
+
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),
|
|
39353
|
+
id: "".concat(nameId, "-label"),
|
|
39354
|
+
htmlFor: labelAs === "label" ? nameId : null,
|
|
39355
|
+
padding: "0"
|
|
39356
|
+
}, srOnlyLabel && /*#__PURE__*/React.createElement("span", {
|
|
39357
|
+
style: SCREEN_READER_ONLY
|
|
39358
|
+
}, srOnlyLabel), label))));
|
|
39325
39359
|
};
|
|
39326
39360
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$y);
|
|
39327
39361
|
|