@bitrise/bitkit 10.18.0-alpha-chakra.2 → 10.18.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/package.json
CHANGED
|
@@ -8,11 +8,11 @@ export default {
|
|
|
8
8
|
|
|
9
9
|
export const WithProps = {
|
|
10
10
|
args: {
|
|
11
|
-
children: 'Toggle the toggle',
|
|
12
11
|
defaultChecked: false,
|
|
13
12
|
helpherText:
|
|
14
13
|
'Inline help. Maecenas a turpis tortor. Nunc vitae libero tempor, ullamcorper purus quis, mattis tellus.',
|
|
15
14
|
isDisabled: false,
|
|
16
15
|
isLoading: false,
|
|
16
|
+
label: 'Toggle the toggle',
|
|
17
17
|
},
|
|
18
18
|
};
|
|
@@ -25,6 +25,9 @@ const ToggleTheme: ComponentStyleConfig = {
|
|
|
25
25
|
backgroundColor: 'turquoise.80',
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
+
_focusVisible: {
|
|
29
|
+
boxShadow: 'outline',
|
|
30
|
+
},
|
|
28
31
|
_before: {
|
|
29
32
|
content: '""',
|
|
30
33
|
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")`,
|
|
@@ -11,14 +11,15 @@ import {
|
|
|
11
11
|
} from '@chakra-ui/react';
|
|
12
12
|
import Text from '../Text/Text';
|
|
13
13
|
|
|
14
|
-
export interface ToggleProps extends FormControlProps {
|
|
15
|
-
|
|
14
|
+
export interface ToggleProps extends Omit<FormControlProps, 'label'> {
|
|
15
|
+
dataTestid?: string;
|
|
16
16
|
defaultChecked?: SwitchProps['defaultChecked'];
|
|
17
17
|
id?: SwitchProps['id'];
|
|
18
18
|
isChecked?: SwitchProps['isChecked'];
|
|
19
19
|
isDisabled?: SwitchProps['isDisabled'];
|
|
20
20
|
isLoading?: boolean;
|
|
21
21
|
helpherText?: string;
|
|
22
|
+
label?: ReactNode;
|
|
22
23
|
onChange?: SwitchProps['onChange'];
|
|
23
24
|
value?: SwitchProps['value'];
|
|
24
25
|
}
|
|
@@ -27,9 +28,21 @@ export interface ToggleProps extends FormControlProps {
|
|
|
27
28
|
* The Toggle component is used as an alternative for the checkbox component.
|
|
28
29
|
*/
|
|
29
30
|
const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
|
|
30
|
-
const {
|
|
31
|
-
|
|
31
|
+
const {
|
|
32
|
+
dataTestid,
|
|
33
|
+
defaultChecked,
|
|
34
|
+
helpherText,
|
|
35
|
+
id,
|
|
36
|
+
isChecked,
|
|
37
|
+
isDisabled,
|
|
38
|
+
isLoading,
|
|
39
|
+
label,
|
|
40
|
+
onChange,
|
|
41
|
+
value,
|
|
42
|
+
...rest
|
|
43
|
+
} = props;
|
|
32
44
|
const switchProps = {
|
|
45
|
+
dataTestid,
|
|
33
46
|
defaultChecked,
|
|
34
47
|
id,
|
|
35
48
|
isChecked,
|
|
@@ -42,7 +55,7 @@ const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
|
|
|
42
55
|
<FormControl sx={css.formControl} {...rest} ref={ref}>
|
|
43
56
|
<Switch {...switchProps} />
|
|
44
57
|
<FormLabel sx={css.label} htmlFor={id}>
|
|
45
|
-
{
|
|
58
|
+
{label}
|
|
46
59
|
</FormLabel>
|
|
47
60
|
{isLoading && <Spinner sx={css.spinner} />}
|
|
48
61
|
{helpherText && <Text sx={css.helpherText}>{helpherText}</Text>}
|