@homebound/beam 2.331.0 → 2.331.1
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/inputs/Switch.d.ts +1 -1
- package/dist/inputs/Switch.js +17 -12
- package/package.json +1 -1
package/dist/inputs/Switch.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface SwitchProps {
|
|
|
10
10
|
label: string;
|
|
11
11
|
/** Where to put the label. */
|
|
12
12
|
labelStyle?: "form" | "inline" | "filter" | "hidden" | "left" | "centered";
|
|
13
|
-
/** Whether
|
|
13
|
+
/** Whether to hide the label */
|
|
14
14
|
hideLabel?: boolean;
|
|
15
15
|
/** Handler when the interactive element state changes. */
|
|
16
16
|
onChange: (value: boolean) => void;
|
package/dist/inputs/Switch.js
CHANGED
|
@@ -19,8 +19,9 @@ function Switch(props) {
|
|
|
19
19
|
const { isFocusVisible: isKeyboardFocus, focusProps } = (0, react_aria_1.useFocusRing)(otherProps);
|
|
20
20
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
|
|
21
21
|
const tooltip = (0, components_1.resolveTooltip)(disabled, props.tooltip);
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const tid = (0, utils_1.useTestIds)(otherProps, label);
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("label", { ...hoverProps, css: {
|
|
24
|
+
...Css_1.Css.relative.cursorPointer.df.wmaxc.selectNone.$,
|
|
24
25
|
...(labelStyle === "form" && Css_1.Css.fdc.$),
|
|
25
26
|
...(labelStyle === "left" && Css_1.Css.w100.aic.$),
|
|
26
27
|
...(labelStyle === "inline" && Css_1.Css.gap2.aic.$),
|
|
@@ -38,7 +39,7 @@ function Switch(props) {
|
|
|
38
39
|
...switchCircleDefaultStyles(compact),
|
|
39
40
|
...(isDisabled && Css_1.Css.bgGray100.$),
|
|
40
41
|
...(isSelected && switchCircleSelectedStyles(compact)),
|
|
41
|
-
}, children: withIcon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isSelected ? "check" : "x", color: isSelected ? Css_1.Palette.Blue700 : Css_1.Palette.Gray400 })) }) }), labelStyle === "inline" && ((0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, tooltip: tooltip, inline: true, xss: Css_1.Css.smMd.gray900.if(compact).add("lineHeight", "1").$ })), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...inputProps, ...focusProps }) })] }));
|
|
42
|
+
}, children: withIcon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isSelected ? "check" : "x", color: isSelected ? Css_1.Palette.Blue700 : Css_1.Palette.Gray400 })) }) }), labelStyle === "inline" && ((0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, tooltip: tooltip, inline: true, xss: Css_1.Css.smMd.gray900.if(compact).add("lineHeight", "1").$ })), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...inputProps, ...focusProps, ...tid }) })] }));
|
|
42
43
|
}
|
|
43
44
|
exports.Switch = Switch;
|
|
44
45
|
/** Styles */
|
|
@@ -50,20 +51,24 @@ exports.switchHoverStyles = Css_1.Css.bgGray400.$;
|
|
|
50
51
|
exports.switchFocusStyles = Css_1.Css.bshFocus.$;
|
|
51
52
|
exports.switchSelectedHoverStyles = Css_1.Css.bgBlue900.$;
|
|
52
53
|
// Circle inside Switcher/Toggle element styles
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
function switchCircleDefaultStyles(isCompact) {
|
|
55
|
+
return {
|
|
56
|
+
...Css_1.Css.wPx(circleDiameter(isCompact))
|
|
57
|
+
.hPx(circleDiameter(isCompact))
|
|
58
|
+
.br100.bgWhite.bshBasic.absolute.leftPx(2)
|
|
59
|
+
.topPx(2).transition.df.aic.jcc.$,
|
|
60
|
+
svg: Css_1.Css.hPx(toggleHeight(isCompact) / 2).wPx(toggleHeight(isCompact) / 2).$,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
60
63
|
/**
|
|
61
64
|
* Affecting the `left` property due to transitions only working when there is
|
|
62
65
|
* a previous value to work from.
|
|
63
66
|
*
|
|
64
|
-
* Calculation is as
|
|
67
|
+
* Calculation is as follows:
|
|
65
68
|
* - `100%` is the toggle width
|
|
66
69
|
* - `${circleDiameter(isCompact)}px` is the circle diameter
|
|
67
70
|
* - `2px` is to keep 2px edge spacing.
|
|
68
71
|
*/
|
|
69
|
-
|
|
72
|
+
function switchCircleSelectedStyles(isCompact) {
|
|
73
|
+
return Css_1.Css.left(`calc(100% - ${circleDiameter(isCompact)}px - 2px);`).$;
|
|
74
|
+
}
|