@carrier-dpx/air-react-library 0.7.31 → 0.7.32
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/package.json +1 -1
- package/src/components/Backdrop/Backdrop.figma.tsx +30 -0
- package/src/components/Backdrop/Backdrop.tsx +35 -0
- package/src/components/Backdrop/index.ts +3 -0
- package/src/components/Checkbox/Checkbox.figma.tsx +128 -0
- package/src/components/Checkbox/Checkbox.tsx +134 -0
- package/src/components/Checkbox/index.ts +3 -0
- package/src/components/Checkbox/styles.ts +111 -0
- package/src/components/Radio/Radio.figma.tsx +120 -0
- package/src/components/Radio/Radio.tsx +97 -0
- package/src/components/Radio/index.ts +3 -0
- package/src/components/Radio/styles.ts +107 -0
- package/src/components/StatusLed/StatusLed.tsx +1 -0
- package/src/components/Switch/Switch.figma.tsx +120 -0
- package/src/components/Switch/Switch.tsx +479 -0
- package/src/components/Switch/index.ts +3 -0
- package/src/components/utils/SwitchUtils.ts +25 -0
- package/src/index.ts +8 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Theme } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const baseRadioSx = (theme: Theme, disableHover: boolean) => ({
|
|
4
|
+
"&.Mui-disabled": {
|
|
5
|
+
svg: {
|
|
6
|
+
stroke: theme.palette.base?.text.disabled,
|
|
7
|
+
},
|
|
8
|
+
fill: theme.palette.base?.text.disabled,
|
|
9
|
+
stroke: theme.palette.base?.text.disabled,
|
|
10
|
+
},
|
|
11
|
+
svg: {
|
|
12
|
+
stroke: theme.palette.base?.state.active,
|
|
13
|
+
strokeWidth: 0,
|
|
14
|
+
},
|
|
15
|
+
p: 0,
|
|
16
|
+
...(disableHover && {
|
|
17
|
+
"&:hover": {
|
|
18
|
+
backgroundColor: "transparent",
|
|
19
|
+
},
|
|
20
|
+
"&.Mui-checked:hover": {
|
|
21
|
+
backgroundColor: "transparent",
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
fill: theme.palette.primary?.main,
|
|
25
|
+
stroke: theme.palette.base?.standardInputLine,
|
|
26
|
+
"&.Mui-checked": {
|
|
27
|
+
stroke: theme.palette.primary?.main,
|
|
28
|
+
},
|
|
29
|
+
"&.MuiRadio-colorError": {
|
|
30
|
+
fill: theme.palette.error?.main,
|
|
31
|
+
stroke: theme.palette.base?.standardInputLine,
|
|
32
|
+
"&.Mui-checked": {
|
|
33
|
+
stroke: theme.palette.error?.main,
|
|
34
|
+
},
|
|
35
|
+
"&.Mui-disabled": {
|
|
36
|
+
fill: theme.palette.base?.text.disabled,
|
|
37
|
+
stroke: theme.palette.base?.text.disabled,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
"&.MuiRadio-colorWarning": {
|
|
41
|
+
fill: theme.palette.warning?.main,
|
|
42
|
+
stroke: theme.palette.base?.standardInputLine,
|
|
43
|
+
"&.Mui-checked": {
|
|
44
|
+
stroke: theme.palette.warning?.main,
|
|
45
|
+
},
|
|
46
|
+
"&.Mui-disabled": {
|
|
47
|
+
fill: theme.palette.base?.text.disabled,
|
|
48
|
+
stroke: theme.palette.base?.text.disabled,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
"&.MuiRadio-colorSuccess": {
|
|
52
|
+
fill: theme.palette.success?.main,
|
|
53
|
+
stroke: theme.palette.base?.standardInputLine,
|
|
54
|
+
"&.Mui-checked": {
|
|
55
|
+
stroke: theme.palette.success?.main,
|
|
56
|
+
},
|
|
57
|
+
"&.Mui-disabled": {
|
|
58
|
+
fill: theme.palette.base?.text.disabled,
|
|
59
|
+
stroke: theme.palette.base?.text.disabled,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
"&.MuiRadio-colorInfo": {
|
|
63
|
+
fill: theme.palette.info?.main,
|
|
64
|
+
stroke: theme.palette.base?.standardInputLine,
|
|
65
|
+
"&.Mui-checked": {
|
|
66
|
+
stroke: theme.palette.info?.main,
|
|
67
|
+
},
|
|
68
|
+
"&.Mui-disabled": {
|
|
69
|
+
fill: theme.palette.base?.text.disabled,
|
|
70
|
+
stroke: theme.palette.base?.text.disabled,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
"&.MuiRadio-colorBase": {
|
|
74
|
+
fill: theme.palette.base?.main,
|
|
75
|
+
stroke: theme.palette.base?.state.active,
|
|
76
|
+
"&.Mui-checked": {
|
|
77
|
+
stroke: theme.palette.base?.main,
|
|
78
|
+
},
|
|
79
|
+
"&.Mui-disabled": {
|
|
80
|
+
fill: theme.palette.base?.state.disabledContent,
|
|
81
|
+
stroke: theme.palette.base?.state.disabledContent,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
"&.MuiRadio-colorSecondary": {
|
|
85
|
+
fill: theme.palette.secondary.main,
|
|
86
|
+
stroke: theme.palette.base?.standardInputLine,
|
|
87
|
+
"&.Mui-checked": {
|
|
88
|
+
stroke: theme.palette.secondary.dark,
|
|
89
|
+
color: theme.palette.secondary.dark,
|
|
90
|
+
},
|
|
91
|
+
"&.Mui-disabled": {
|
|
92
|
+
fill: theme.palette.base?.state.disabledContent,
|
|
93
|
+
stroke: theme.palette.base?.state.disabledContent,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
colorSecondary: {
|
|
97
|
+
fill: theme.palette.secondary?.main,
|
|
98
|
+
"&.Mui-checked": {
|
|
99
|
+
color: theme.palette.secondary?.dark,
|
|
100
|
+
stroke: theme.palette.secondary?.dark,
|
|
101
|
+
},
|
|
102
|
+
"&.Mui-disabled": {
|
|
103
|
+
fill: theme.palette.base?.text.disabled,
|
|
104
|
+
stroke: theme.palette.base?.text.disabled,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Code Connect Configuration for Switch Component
|
|
3
|
+
*
|
|
4
|
+
* Figma URL: https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=6564-39128
|
|
5
|
+
*
|
|
6
|
+
* Figma Properties:
|
|
7
|
+
* - size (medium-40px, small-32px)
|
|
8
|
+
* - checked (true, false)
|
|
9
|
+
* - disabled (true, false)
|
|
10
|
+
* - color (primary, secondary, base, error, warning, success, info)
|
|
11
|
+
* - state (enabled, hover, focus) - visual state, not a prop
|
|
12
|
+
* - labelPosition (end, start, top, bottom)
|
|
13
|
+
* - showLabel (true, false)
|
|
14
|
+
* - ✏️ Text (text label with layer name "Label")
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import figma from "@figma/code-connect";
|
|
18
|
+
import Switch from "./Switch";
|
|
19
|
+
import { FormControlLabel } from "@mui/material";
|
|
20
|
+
|
|
21
|
+
figma.connect(
|
|
22
|
+
Switch,
|
|
23
|
+
"https://www.figma.com/design/vkoHdM6rchIhH9IWetZeP0/Air--Components?node-id=6564-39128",
|
|
24
|
+
{
|
|
25
|
+
props: {
|
|
26
|
+
/**
|
|
27
|
+
* SIZE MAPPING
|
|
28
|
+
* Maps Figma's "size" property to React's "size" prop
|
|
29
|
+
* Figma: medium (40px), small (32px)
|
|
30
|
+
*/
|
|
31
|
+
size: figma.enum("size", {
|
|
32
|
+
"medium-40px": "medium",
|
|
33
|
+
"small-32px": "small",
|
|
34
|
+
// Handle cases where Figma might show just the size name
|
|
35
|
+
medium: "medium",
|
|
36
|
+
small: "small",
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* CHECKED STATE
|
|
41
|
+
* Maps Figma's "checked" boolean to React's "checked" prop
|
|
42
|
+
*/
|
|
43
|
+
checked: figma.boolean("checked"),
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* DISABLED STATE
|
|
47
|
+
* Maps Figma's "disabled" boolean to React's "disabled" prop
|
|
48
|
+
*/
|
|
49
|
+
disabled: figma.boolean("disabled"),
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* COLOR MAPPING
|
|
53
|
+
* Maps Figma's "color" property to React's "color" prop
|
|
54
|
+
*/
|
|
55
|
+
color: figma.enum("color", {
|
|
56
|
+
primary: "primary",
|
|
57
|
+
secondary: "secondary",
|
|
58
|
+
base: "base",
|
|
59
|
+
error: "error",
|
|
60
|
+
warning: "warning",
|
|
61
|
+
success: "success",
|
|
62
|
+
info: "info",
|
|
63
|
+
}),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* LABEL POSITION
|
|
67
|
+
* Maps Figma's "labelPosition" property
|
|
68
|
+
* Used with FormControlLabel to position the label
|
|
69
|
+
*/
|
|
70
|
+
labelPosition: figma.enum("labelPosition", {
|
|
71
|
+
end: "end",
|
|
72
|
+
start: "start",
|
|
73
|
+
top: "top",
|
|
74
|
+
bottom: "bottom",
|
|
75
|
+
}),
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* LABEL VISIBILITY
|
|
79
|
+
* Maps Figma's "showLabel" boolean property
|
|
80
|
+
* When true, shows the label; when false, hides it
|
|
81
|
+
*/
|
|
82
|
+
showLabel: figma.boolean("showLabel"),
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* LABEL TEXT CONTENT
|
|
86
|
+
* Maps text property "✏️ Text" from the "Label" layer
|
|
87
|
+
* The text property must be surfaced from the "Label" layer
|
|
88
|
+
*/
|
|
89
|
+
label: figma.string("✏️ Text"),
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* EXAMPLE CODE TEMPLATE
|
|
94
|
+
* Shows how Switch should be used, optionally with FormControlLabel for labels
|
|
95
|
+
*/
|
|
96
|
+
example: ({ size, checked, disabled, color, labelPosition, showLabel, label }) => {
|
|
97
|
+
const switchComponent = (
|
|
98
|
+
<Switch
|
|
99
|
+
size={size}
|
|
100
|
+
checked={checked}
|
|
101
|
+
disabled={disabled}
|
|
102
|
+
color={color}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// If label should be shown, wrap with FormControlLabel
|
|
107
|
+
if (showLabel && label) {
|
|
108
|
+
return (
|
|
109
|
+
<FormControlLabel
|
|
110
|
+
control={switchComponent}
|
|
111
|
+
label={label}
|
|
112
|
+
labelPlacement={labelPosition || "end"}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return switchComponent;
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
);
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { forwardRef, Ref } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
alpha,
|
|
5
|
+
Switch as MuiSwitch,
|
|
6
|
+
SwitchProps as MuiSwitchProps,
|
|
7
|
+
} from "@mui/material";
|
|
8
|
+
|
|
9
|
+
import { styled } from "@mui/material/styles";
|
|
10
|
+
import { TouchRippleActions } from "@mui/material/ButtonBase/TouchRipple";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
activeShadowAlpha,
|
|
14
|
+
baseMargin,
|
|
15
|
+
basePadding,
|
|
16
|
+
baseTransitionDuration,
|
|
17
|
+
baseShadowVariant,
|
|
18
|
+
TrackWidthMap,
|
|
19
|
+
TrackHeightMap,
|
|
20
|
+
ThumbSizeMap,
|
|
21
|
+
ShadowRadiusMap,
|
|
22
|
+
} from "../utils/SwitchUtils";
|
|
23
|
+
import fleetPalette from "../theme/constants/colors";
|
|
24
|
+
|
|
25
|
+
export interface SwitchProps extends Omit<MuiSwitchProps, "color"> {
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* Colors that make sense for this component
|
|
29
|
+
* @default primary
|
|
30
|
+
*/
|
|
31
|
+
color?:
|
|
32
|
+
| "base"
|
|
33
|
+
| "primary"
|
|
34
|
+
| "secondary"
|
|
35
|
+
| "warning"
|
|
36
|
+
| "success"
|
|
37
|
+
| "info"
|
|
38
|
+
| "error";
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* A ref that points to the TouchRipple element.
|
|
42
|
+
*/
|
|
43
|
+
touchRippleRef?: Ref<TouchRippleActions>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// overriding MUI switch style to match Air switch style
|
|
47
|
+
const StyledMuiSwitch = styled(MuiSwitch)<MuiSwitchProps>(({ theme }) => ({
|
|
48
|
+
"&.MuiSwitch-root": {
|
|
49
|
+
"& .MuiSwitch-switchBase": {
|
|
50
|
+
"& + .MuiSwitch-track": {
|
|
51
|
+
backgroundColor: theme.palette.base?.state.disabledContent,
|
|
52
|
+
borderRadius: 10,
|
|
53
|
+
opacity: 1,
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
57
|
+
borderRadius: "100%",
|
|
58
|
+
boxShadow: theme.shadows[baseShadowVariant],
|
|
59
|
+
boxSizing: "border-box",
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
"& .MuiSwitch-thumb, & > svg, & + .MuiSwitch-track": {
|
|
63
|
+
transition: theme.transitions.create(["background-color", "color"], {
|
|
64
|
+
duration: theme.transitions.duration.standard,
|
|
65
|
+
easing: theme.transitions.easing.easeInOut,
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"& > svg": {
|
|
70
|
+
backgroundColor: theme.palette.background.default,
|
|
71
|
+
color: theme.palette.action.disabled,
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
//Common white token applied to Checked Thumb for all colors
|
|
75
|
+
"&.Mui-checked .MuiSwitch-thumb": {
|
|
76
|
+
backgroundColor: theme.palette.base?.common.white,
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
"&.Mui-checked:not(.Mui-disabled)": {
|
|
80
|
+
"&.MuiSwitch-colorDefault": {
|
|
81
|
+
"& + .MuiSwitch-track": {
|
|
82
|
+
backgroundColor: theme.palette.primary.main,
|
|
83
|
+
opacity: 1,
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
"& > svg": {
|
|
87
|
+
backgroundColor: theme.palette.primary.main,
|
|
88
|
+
color: theme.palette.primary.contrastText,
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
color: theme.palette.primary.main,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
"&.MuiSwitch-colorError": {
|
|
95
|
+
"& + .MuiSwitch-track": {
|
|
96
|
+
backgroundColor: theme.palette.error.main,
|
|
97
|
+
opacity: 1,
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
"& > svg": {
|
|
101
|
+
backgroundColor: theme.palette.error.main,
|
|
102
|
+
color: theme.palette.error.contrastText,
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
color: theme.palette.error.main,
|
|
106
|
+
},
|
|
107
|
+
"&.MuiSwitch-colorBase": {
|
|
108
|
+
"& + .MuiSwitch-track": {
|
|
109
|
+
backgroundColor: theme.palette.base?.state.active,
|
|
110
|
+
opacity: 1,
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
"&:hover, &.Mui-focusVisible": {
|
|
114
|
+
"&.MuiSwitch-colorBase": {
|
|
115
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
116
|
+
boxShadow: `
|
|
117
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
118
|
+
fleetPalette.base?.dark,
|
|
119
|
+
activeShadowAlpha
|
|
120
|
+
)},
|
|
121
|
+
${theme.shadows[baseShadowVariant]}`,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
"&.Mui-disabled": {
|
|
126
|
+
"&.MuiSwitch-colorBase": {
|
|
127
|
+
"& + .MuiSwitch-track": {
|
|
128
|
+
backgroundColor: theme.palette.base?.state.disabledBackground,
|
|
129
|
+
opacity: 1,
|
|
130
|
+
},
|
|
131
|
+
"& .MuiSwitch-thumb": {
|
|
132
|
+
backgroundColor: theme.palette.base?.background.paper,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
"&.MuiSwitch-colorInfo": {
|
|
139
|
+
"& + .MuiSwitch-track": {
|
|
140
|
+
backgroundColor: theme.palette.info.main,
|
|
141
|
+
opacity: 1,
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
"& > svg": {
|
|
145
|
+
backgroundColor: theme.palette.info.main,
|
|
146
|
+
color: theme.palette.info.contrastText,
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
color: theme.palette.info.main,
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
"&.MuiSwitch-colorPrimary": {
|
|
153
|
+
"& + .MuiSwitch-track": {
|
|
154
|
+
backgroundColor: theme.palette.primary.main,
|
|
155
|
+
opacity: 1,
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
"& > svg": {
|
|
159
|
+
backgroundColor: theme.palette.primary.main,
|
|
160
|
+
color: theme.palette.primary.contrastText,
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
color: theme.palette.primary.main,
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
"&.MuiSwitch-colorSecondary": {
|
|
167
|
+
"& + .MuiSwitch-track": {
|
|
168
|
+
backgroundColor: theme.palette.secondary.light,
|
|
169
|
+
opacity: 1,
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
"& > svg": {
|
|
173
|
+
backgroundColor: theme.palette.secondary.main,
|
|
174
|
+
color: theme.palette.secondary.contrastText,
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
color: theme.palette.secondary.main,
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
"&.MuiSwitch-colorSuccess": {
|
|
181
|
+
"& + .MuiSwitch-track": {
|
|
182
|
+
backgroundColor: theme.palette.success.main,
|
|
183
|
+
opacity: 1,
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
"& > svg": {
|
|
187
|
+
backgroundColor: theme.palette.success.main,
|
|
188
|
+
color: theme.palette.success.contrastText,
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
color: theme.palette.success.main,
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
"&.MuiSwitch-colorWarning": {
|
|
195
|
+
"& + .MuiSwitch-track": {
|
|
196
|
+
backgroundColor: theme.palette.warning.main,
|
|
197
|
+
opacity: 1,
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
"& > svg": {
|
|
201
|
+
backgroundColor: theme.palette.warning.main,
|
|
202
|
+
color: theme.palette.warning.contrastText,
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
color: theme.palette.warning.main,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
"&.Mui-disabled": {
|
|
210
|
+
"& + .MuiSwitch-track": {
|
|
211
|
+
backgroundColor: theme.palette.action.disabledBackground,
|
|
212
|
+
opacity: 1,
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
"& .MuiSwitch-thumb": {
|
|
216
|
+
color: theme.palette.background.default,
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
"& > svg": {
|
|
220
|
+
backgroundColor: theme.palette.background.default,
|
|
221
|
+
color: theme.palette.action.disabled,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
margin: baseMargin,
|
|
226
|
+
padding: basePadding,
|
|
227
|
+
transitionDuration: baseTransitionDuration,
|
|
228
|
+
},
|
|
229
|
+
overflow: "visible",
|
|
230
|
+
padding: basePadding,
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
"&.MuiSwitch-sizeMedium": {
|
|
234
|
+
"& .MuiSwitch-switchBase": {
|
|
235
|
+
"&.Mui-checked": {
|
|
236
|
+
"&:hover, &.Mui-focusVisible": {
|
|
237
|
+
"&.MuiSwitch-colorDefault": {
|
|
238
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
239
|
+
boxShadow: `
|
|
240
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
241
|
+
theme.palette.primary.main,
|
|
242
|
+
activeShadowAlpha
|
|
243
|
+
)},
|
|
244
|
+
${theme.shadows[baseShadowVariant]}
|
|
245
|
+
`,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
"&.MuiSwitch-colorError": {
|
|
250
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
251
|
+
boxShadow: `
|
|
252
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
253
|
+
theme.palette.error.main,
|
|
254
|
+
activeShadowAlpha
|
|
255
|
+
)},
|
|
256
|
+
${theme.shadows[baseShadowVariant]}
|
|
257
|
+
`,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
"&.MuiSwitch-colorInfo": {
|
|
262
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
263
|
+
boxShadow: `
|
|
264
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
265
|
+
theme.palette.info.main,
|
|
266
|
+
activeShadowAlpha
|
|
267
|
+
)},
|
|
268
|
+
${theme.shadows[baseShadowVariant]}
|
|
269
|
+
`,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
"&.MuiSwitch-colorPrimary": {
|
|
274
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
275
|
+
boxShadow: `
|
|
276
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
277
|
+
theme.palette.primary.main,
|
|
278
|
+
activeShadowAlpha
|
|
279
|
+
)},
|
|
280
|
+
${theme.shadows[baseShadowVariant]}
|
|
281
|
+
`,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
"&.MuiSwitch-colorSecondary": {
|
|
286
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
287
|
+
boxShadow: `
|
|
288
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
289
|
+
theme.palette.secondary.main,
|
|
290
|
+
activeShadowAlpha
|
|
291
|
+
)},
|
|
292
|
+
${theme.shadows[baseShadowVariant]}
|
|
293
|
+
`,
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
"&.MuiSwitch-colorSuccess": {
|
|
298
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
299
|
+
boxShadow: `
|
|
300
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
301
|
+
theme.palette.success.main,
|
|
302
|
+
activeShadowAlpha
|
|
303
|
+
)},
|
|
304
|
+
${theme.shadows[baseShadowVariant]}
|
|
305
|
+
`,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
"&.MuiSwitch-colorWarning": {
|
|
310
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
311
|
+
boxShadow: `
|
|
312
|
+
0 0 0 ${ShadowRadiusMap.medium} ${alpha(
|
|
313
|
+
theme.palette.warning.main,
|
|
314
|
+
activeShadowAlpha
|
|
315
|
+
)},
|
|
316
|
+
${theme.shadows[baseShadowVariant]}
|
|
317
|
+
`,
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
transform: "translateX(18px)",
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
"&:hover .MuiSwitch-thumb, &.Mui-focusVisible .MuiSwitch-thumb, &:hover > svg, &.Mui-focusVisible > svg":
|
|
326
|
+
{
|
|
327
|
+
boxShadow: `
|
|
328
|
+
0 0 0 ${ShadowRadiusMap.medium} ${theme.palette.action.hover},
|
|
329
|
+
${theme.shadows[baseShadowVariant]}
|
|
330
|
+
`,
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
"& .MuiSwitch-thumb, & svg": {
|
|
335
|
+
height: ThumbSizeMap.medium,
|
|
336
|
+
width: ThumbSizeMap.medium,
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
height: TrackHeightMap.medium,
|
|
340
|
+
width: TrackWidthMap.medium,
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
"&.MuiSwitch-sizeSmall": {
|
|
344
|
+
"& .MuiSwitch-switchBase": {
|
|
345
|
+
"&.Mui-checked": {
|
|
346
|
+
"&:hover, &.Mui-focusVisible": {
|
|
347
|
+
"&.MuiSwitch-colorDefault": {
|
|
348
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
349
|
+
boxShadow: `
|
|
350
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
351
|
+
theme.palette.primary.main,
|
|
352
|
+
activeShadowAlpha
|
|
353
|
+
)},
|
|
354
|
+
${theme.shadows[baseShadowVariant]}
|
|
355
|
+
`,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
"&.MuiSwitch-colorError": {
|
|
360
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
361
|
+
boxShadow: `
|
|
362
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
363
|
+
theme.palette.error.main,
|
|
364
|
+
activeShadowAlpha
|
|
365
|
+
)},
|
|
366
|
+
${theme.shadows[baseShadowVariant]}
|
|
367
|
+
`,
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
"&.MuiSwitch-colorBase": {
|
|
371
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
372
|
+
boxShadow: `
|
|
373
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
374
|
+
theme.palette.secondary.main,
|
|
375
|
+
activeShadowAlpha
|
|
376
|
+
)},
|
|
377
|
+
${theme.shadows[baseShadowVariant]}
|
|
378
|
+
`,
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
"&.MuiSwitch-colorInfo": {
|
|
383
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
384
|
+
boxShadow: `
|
|
385
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
386
|
+
theme.palette.info.main,
|
|
387
|
+
activeShadowAlpha
|
|
388
|
+
)},
|
|
389
|
+
${theme.shadows[baseShadowVariant]}
|
|
390
|
+
`,
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
"&.MuiSwitch-colorPrimary": {
|
|
395
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
396
|
+
boxShadow: `
|
|
397
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
398
|
+
theme.palette.primary.main,
|
|
399
|
+
activeShadowAlpha
|
|
400
|
+
)},
|
|
401
|
+
${theme.shadows[baseShadowVariant]}
|
|
402
|
+
`,
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
"&.MuiSwitch-colorSecondary": {
|
|
407
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
408
|
+
boxShadow: `
|
|
409
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
410
|
+
theme.palette.secondary.main,
|
|
411
|
+
activeShadowAlpha
|
|
412
|
+
)},
|
|
413
|
+
${theme.shadows[baseShadowVariant]}
|
|
414
|
+
`,
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
"&.MuiSwitch-colorSuccess": {
|
|
419
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
420
|
+
boxShadow: `
|
|
421
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
422
|
+
theme.palette.success.main,
|
|
423
|
+
activeShadowAlpha
|
|
424
|
+
)},
|
|
425
|
+
${theme.shadows[baseShadowVariant]}
|
|
426
|
+
`,
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
"&.MuiSwitch-colorWarning": {
|
|
431
|
+
"& .MuiSwitch-thumb, & > svg": {
|
|
432
|
+
boxShadow: `
|
|
433
|
+
0 0 0 ${ShadowRadiusMap.small} ${alpha(
|
|
434
|
+
theme.palette.warning.main,
|
|
435
|
+
activeShadowAlpha
|
|
436
|
+
)},
|
|
437
|
+
${theme.shadows[baseShadowVariant]}
|
|
438
|
+
`,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
|
|
443
|
+
transform: "translateX(16px)",
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
"&:hover .MuiSwitch-thumb, &.Mui-focusVisible .MuiSwitch-thumb, &:hover > svg, &.Mui-focusVisible > svg":
|
|
447
|
+
{
|
|
448
|
+
boxShadow: `
|
|
449
|
+
0 0 0 ${ShadowRadiusMap.small} ${theme.palette.action.hover},
|
|
450
|
+
${theme.shadows[baseShadowVariant]}
|
|
451
|
+
`,
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
"& .MuiSwitch-thumb, & svg": {
|
|
456
|
+
height: ThumbSizeMap.small,
|
|
457
|
+
width: ThumbSizeMap.small,
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
height: TrackHeightMap.small,
|
|
461
|
+
width: TrackWidthMap.small,
|
|
462
|
+
},
|
|
463
|
+
}));
|
|
464
|
+
|
|
465
|
+
/** The Switch component turns the state of a single setting on or off.
|
|
466
|
+
*
|
|
467
|
+
* `import Switch from '@carrier-io/air-react/Switch'`;
|
|
468
|
+
*/
|
|
469
|
+
|
|
470
|
+
const Switch = forwardRef<HTMLButtonElement, SwitchProps>(
|
|
471
|
+
({ color = "primary", ...otherProps }, ref) => {
|
|
472
|
+
return <StyledMuiSwitch color={color as any} {...otherProps} ref={ref} />;
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
Switch.displayName = "Switch";
|
|
477
|
+
|
|
478
|
+
export default Switch;
|
|
479
|
+
export type { SwitchProps };
|