@bitrise/bitkit 12.28.4 → 12.29.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/package.json
CHANGED
|
@@ -1,79 +1,83 @@
|
|
|
1
1
|
import type { ComponentStyleConfig } from '@chakra-ui/theme';
|
|
2
2
|
|
|
3
3
|
const ToggleTheme: ComponentStyleConfig = {
|
|
4
|
-
baseStyle: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
width: '48',
|
|
12
|
-
height: '24',
|
|
13
|
-
padding: '0.125rem',
|
|
14
|
-
backgroundColor: 'neutral.50',
|
|
15
|
-
borderRadius: '12',
|
|
16
|
-
transition: '100ms',
|
|
17
|
-
isolation: 'isolate',
|
|
18
|
-
_disabled: {
|
|
19
|
-
backgroundColor: 'neutral.93',
|
|
20
|
-
cursor: 'not-allowed',
|
|
4
|
+
baseStyle: ({ withTooltip }) => {
|
|
5
|
+
return {
|
|
6
|
+
labelWrapper: {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
gap: '8',
|
|
9
|
+
paddingInlineEnd: withTooltip ? '4' : undefined,
|
|
10
|
+
width: withTooltip ? 'fit-content' : undefined,
|
|
21
11
|
},
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
track: {
|
|
13
|
+
boxSizing: 'border-box',
|
|
14
|
+
width: '48',
|
|
15
|
+
height: '24',
|
|
16
|
+
padding: '0.125rem',
|
|
17
|
+
backgroundColor: 'neutral.50',
|
|
18
|
+
borderRadius: '12',
|
|
19
|
+
transition: '100ms',
|
|
20
|
+
isolation: 'isolate',
|
|
24
21
|
_disabled: {
|
|
25
|
-
backgroundColor: '
|
|
22
|
+
backgroundColor: 'neutral.93',
|
|
23
|
+
cursor: 'not-allowed',
|
|
24
|
+
},
|
|
25
|
+
_checked: {
|
|
26
|
+
backgroundColor: 'turquoise.70',
|
|
27
|
+
_disabled: {
|
|
28
|
+
backgroundColor: 'turquoise.80',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
_focusVisible: {
|
|
32
|
+
boxShadow: 'outline',
|
|
33
|
+
},
|
|
34
|
+
_before: {
|
|
35
|
+
content: '""',
|
|
36
|
+
backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.213 13.915 17.234 7l1.49 1.49L10.212 17 5 11.68l1.49-1.489 3.723 3.724Z' fill='white' /%3E%3C/svg%3E")`,
|
|
37
|
+
backgroundPositionX: '0.125rem',
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
left: 0,
|
|
40
|
+
right: '50%',
|
|
41
|
+
top: 0,
|
|
42
|
+
bottom: 0,
|
|
43
|
+
},
|
|
44
|
+
_after: {
|
|
45
|
+
content: '""',
|
|
46
|
+
backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12.01 10.608 16.618 6l1.402 1.402-4.608 4.608 4.608 4.608-1.402 1.402-4.608-4.608-4.608 4.608L6 16.618l4.608-4.608L6 7.402 7.402 6l4.608 4.608Z' fill='white' /%3E%3C/svg%3E")`,
|
|
47
|
+
backgroundPositionX: '-0.125rem',
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
left: '50%',
|
|
50
|
+
right: 0,
|
|
51
|
+
top: 0,
|
|
52
|
+
bottom: 0,
|
|
26
53
|
},
|
|
27
54
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
bottom: 0,
|
|
55
|
+
thumb: {
|
|
56
|
+
position: 'relative',
|
|
57
|
+
zIndex: '1',
|
|
58
|
+
width: '1.25rem',
|
|
59
|
+
height: '1.25rem',
|
|
60
|
+
borderRadius: '24',
|
|
61
|
+
bgGradient: 'linear(to-b, neutral.93 3.43%, neutral.100 100%)',
|
|
62
|
+
transition: '100ms',
|
|
63
|
+
_checked: {
|
|
64
|
+
transform: 'translate(24px)',
|
|
65
|
+
},
|
|
40
66
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
left: '50%',
|
|
47
|
-
right: 0,
|
|
48
|
-
top: 0,
|
|
49
|
-
bottom: 0,
|
|
67
|
+
label: {
|
|
68
|
+
fontSize: '3',
|
|
69
|
+
fontWeight: 'normal',
|
|
70
|
+
lineHeight: '1.5rem',
|
|
71
|
+
marginBottom: 0,
|
|
50
72
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
borderRadius: '24',
|
|
58
|
-
bgGradient: 'linear(to-b, neutral.93 3.43%, neutral.100 100%)',
|
|
59
|
-
transition: '100ms',
|
|
60
|
-
_checked: {
|
|
61
|
-
transform: 'translate(24px)',
|
|
73
|
+
spinner: {
|
|
74
|
+
width: '16',
|
|
75
|
+
height: '16',
|
|
76
|
+
marginTop: '4',
|
|
77
|
+
flexShrink: 0,
|
|
78
|
+
color: 'neutral.70',
|
|
62
79
|
},
|
|
63
|
-
}
|
|
64
|
-
label: {
|
|
65
|
-
fontSize: '3',
|
|
66
|
-
fontWeight: 'normal',
|
|
67
|
-
lineHeight: '1.5rem',
|
|
68
|
-
marginBottom: 0,
|
|
69
|
-
},
|
|
70
|
-
spinner: {
|
|
71
|
-
width: '16',
|
|
72
|
-
height: '16',
|
|
73
|
-
marginTop: '4',
|
|
74
|
-
flexShrink: 0,
|
|
75
|
-
color: 'neutral.70',
|
|
76
|
-
},
|
|
80
|
+
};
|
|
77
81
|
},
|
|
78
82
|
};
|
|
79
83
|
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '@chakra-ui/react';
|
|
13
13
|
import Box from '../Box/Box';
|
|
14
14
|
import ProgressSpinner from '../ProgressSpinner/ProgressSpinner';
|
|
15
|
+
import Tooltip, { TooltipProps } from '../Tooltip/Tooltip';
|
|
15
16
|
|
|
16
17
|
export interface ToggleProps extends Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> {
|
|
17
18
|
'data-testid'?: string;
|
|
@@ -26,6 +27,7 @@ export interface ToggleProps extends Omit<FormControlProps, 'label' | 'onBlur' |
|
|
|
26
27
|
name?: string;
|
|
27
28
|
onBlur?: SwitchProps['onBlur'];
|
|
28
29
|
onChange?: SwitchProps['onChange'];
|
|
30
|
+
tooltip?: Omit<TooltipProps, 'children'>;
|
|
29
31
|
value?: SwitchProps['value'];
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -48,6 +50,7 @@ const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
|
|
|
48
50
|
name,
|
|
49
51
|
onBlur,
|
|
50
52
|
onChange,
|
|
53
|
+
tooltip,
|
|
51
54
|
value,
|
|
52
55
|
...rest
|
|
53
56
|
} = props;
|
|
@@ -69,18 +72,20 @@ const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
|
|
|
69
72
|
onChange,
|
|
70
73
|
value,
|
|
71
74
|
};
|
|
72
|
-
const css = useMultiStyleConfig('Switch');
|
|
75
|
+
const css = useMultiStyleConfig('Switch', { withTooltip: !!tooltip });
|
|
73
76
|
return (
|
|
74
77
|
<FormControl {...formControlProps}>
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{label}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
<Tooltip isDisabled={!tooltip} {...tooltip}>
|
|
79
|
+
<Box sx={css.labelWrapper}>
|
|
80
|
+
<Switch {...switchProps} />
|
|
81
|
+
{label && (
|
|
82
|
+
<FormLabel htmlFor={id} sx={css.label}>
|
|
83
|
+
{label}
|
|
84
|
+
</FormLabel>
|
|
85
|
+
)}
|
|
86
|
+
{isLoading && <ProgressSpinner sx={css.spinner} />}
|
|
87
|
+
</Box>
|
|
88
|
+
</Tooltip>
|
|
84
89
|
{errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
|
|
85
90
|
{helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
|
|
86
91
|
</FormControl>
|