@bitrise/bitkit 10.22.1 → 10.23.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "10.22.1",
4
+ "version": "10.23.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -2,7 +2,7 @@ import { Checkbox as ChakraCheckbox, CheckboxProps as ChakraCheckboxProps, forwa
2
2
  import Icon from '../../Icon/Icon';
3
3
 
4
4
  type CheckboxInputProps = ChakraCheckboxProps['inputProps'] & {
5
- 'data-testid': string;
5
+ 'data-testid'?: string;
6
6
  };
7
7
 
8
8
  export interface CheckboxProps extends Omit<ChakraCheckboxProps, 'icon' | 'iconColor' | 'iconSize' | 'inputProps'> {
@@ -24,6 +24,7 @@ const FormTheme = {
24
24
  FormLabel: {
25
25
  baseStyle: {
26
26
  marginBottom: '4',
27
+ fontSize: '2',
27
28
  fontWeight: 'bold',
28
29
  } as ComponentStyleConfig,
29
30
  },
@@ -1,7 +1,7 @@
1
1
  import { Radio as ChakraRadio, RadioProps as ChakraRadioProps, forwardRef } from '@chakra-ui/react';
2
2
 
3
3
  type RadioInputProps = ChakraRadioProps['inputProps'] & {
4
- 'data-testid': string;
4
+ 'data-testid'?: string;
5
5
  };
6
6
 
7
7
  export interface RadioProps extends Omit<ChakraRadioProps, 'inputProps'> {
@@ -8,7 +8,7 @@ export default {
8
8
  export const WithProps = {
9
9
  args: {
10
10
  errorText: '',
11
- helpherText:
11
+ helperText:
12
12
  'Inline help. Maecenas a turpis tortor. Nunc vitae libero tempor, ullamcorper purus quis, mattis tellus.',
13
13
  isDisabled: false,
14
14
  isInvalid: false,
@@ -14,12 +14,17 @@ const TextareaTheme: ComponentStyleConfig = {
14
14
  appearance: 'none',
15
15
  lineHeight: 'short',
16
16
  verticalAlign: 'top',
17
+ transition: '200ms',
18
+ _placeholder: {
19
+ fontStyle: 'italic',
20
+ },
17
21
  _disabled: {
18
22
  background: 'neutral.93',
19
23
  cursor: 'not-allowed',
20
24
  },
21
25
  _focusVisible: {
22
- boxShadow: 'outline',
26
+ boxShadow: 'formFocus',
27
+ borderColor: 'purple.50',
23
28
  },
24
29
  _invalid: {
25
30
  color: 'red.50',
@@ -10,15 +10,15 @@ import {
10
10
  forwardRef,
11
11
  } from '@chakra-ui/react';
12
12
 
13
- export interface TextareaProps extends Omit<FormControlProps, 'label' | 'onChange' | 'onBlur'> {
13
+ export interface TextareaProps extends Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> {
14
14
  'data-testid'?: string;
15
15
  errorText?: string;
16
16
  isLoading?: boolean;
17
- helpherText?: string;
17
+ helperText?: string;
18
18
  label?: ReactNode;
19
19
  name?: string;
20
- onChange?: ChakraTextareaProps['onChange'];
21
20
  onBlur?: ChakraTextareaProps['onBlur'];
21
+ onChange?: ChakraTextareaProps['onChange'];
22
22
  value?: ChakraTextareaProps['value'];
23
23
  }
24
24
 
@@ -29,32 +29,38 @@ const Textarea = forwardRef<TextareaProps, 'div'>((props, ref) => {
29
29
  const {
30
30
  'data-testid': dataTestid,
31
31
  errorText,
32
- helpherText,
32
+ helperText,
33
33
  isDisabled,
34
34
  isInvalid,
35
35
  isLoading,
36
36
  label,
37
37
  placeholder,
38
- onChange,
39
38
  onBlur,
39
+ onChange,
40
40
  name,
41
41
  value,
42
42
  ...rest
43
43
  } = props;
44
+ const formControlProps = {
45
+ isDisabled: isDisabled || isLoading,
46
+ isInvalid: isInvalid || !!errorText,
47
+ ...rest,
48
+ ref,
49
+ };
44
50
  const textareaProps = {
45
51
  'data-testid': dataTestid,
46
- onChange,
47
52
  onBlur,
53
+ onChange,
48
54
  name,
49
55
  placeholder,
50
56
  value,
51
57
  };
52
58
  return (
53
- <FormControl isDisabled={isDisabled || isLoading} isInvalid={isInvalid || !!errorText} {...rest} ref={ref}>
59
+ <FormControl {...formControlProps}>
54
60
  {label && <FormLabel>{label}</FormLabel>}
55
61
  <ChakraTextarea {...textareaProps} />
56
62
  {errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
57
- {helpherText && <FormHelperText as="p">{helpherText}</FormHelperText>}
63
+ {helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
58
64
  </FormControl>
59
65
  );
60
66
  });
@@ -6,6 +6,13 @@ import Select from './Select';
6
6
  export default {
7
7
  title: 'Components/Select',
8
8
  component: Select,
9
+ args: {
10
+ isLoading: false,
11
+ errorText: 'Error text',
12
+ helperText: 'Helpher text',
13
+ label: 'Label',
14
+ name: 'Name',
15
+ },
9
16
  argTypes: {
10
17
  onChange: {
11
18
  action: 'onChange event',
@@ -1,41 +1,89 @@
1
- import { forwardRef, Select as ChakraSelect, SelectProps as ChakraSelectProps, Spinner } from '@chakra-ui/react';
1
+ import { ReactNode } from 'react';
2
+ import {
3
+ FormControl,
4
+ FormControlProps,
5
+ FormErrorMessage,
6
+ FormHelperText,
7
+ FormLabel,
8
+ forwardRef,
9
+ Select as ChakraSelect,
10
+ SelectProps as ChakraSelectProps,
11
+ Spinner,
12
+ } from '@chakra-ui/react';
2
13
  import Icon from '../Icon/Icon';
3
14
 
4
- export interface SelectProps extends ChakraSelectProps {
5
- size?: 'small' | 'medium';
15
+ export interface SelectProps extends Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> {
16
+ 'data-testid'?: string;
17
+ errorText?: string;
18
+ helperText?: string;
6
19
  isLoading?: boolean;
20
+ label?: ReactNode;
21
+ name?: string;
22
+ onBlur?: ChakraSelectProps['onBlur'];
23
+ onChange?: ChakraSelectProps['onChange'];
24
+ size?: 'small' | 'medium';
25
+ value?: ChakraSelectProps['value'];
7
26
  }
8
27
 
9
- const Select = forwardRef<SelectProps, 'select'>((props, ref) => {
10
- const { size, placeholder, children, isDisabled, isLoading, ...rest } = props;
28
+ const Select = forwardRef<SelectProps, 'div'>((props, ref) => {
29
+ const {
30
+ children,
31
+ 'data-testid': dataTestid,
32
+ errorText,
33
+ helperText,
34
+ isDisabled,
35
+ isInvalid,
36
+ isLoading,
37
+ label,
38
+ name,
39
+ onBlur,
40
+ onChange,
41
+ placeholder,
42
+ size,
43
+ value,
44
+ ...rest
45
+ } = props;
11
46
  const iconSize = size === 'medium' ? '24' : '16';
12
- const properties: ChakraSelectProps = {
47
+ const formControlProps = {
48
+ isDisabled: isDisabled || isLoading,
49
+ isInvalid: isInvalid || !!errorText,
50
+ ...rest,
51
+ ref,
52
+ };
53
+ const selectProperties: ChakraSelectProps = {
13
54
  icon: isLoading ? (
14
55
  <Spinner width={iconSize} height={iconSize} marginEnd="4" />
15
56
  ) : (
16
57
  <Icon name="DropdownArrows" fontSize={iconSize} size={iconSize} />
17
58
  ),
18
- isDisabled: isLoading || isDisabled,
59
+ name,
60
+ onBlur,
61
+ onChange,
19
62
  size,
63
+ value,
20
64
  variant: 'select',
21
- ...rest,
22
65
  };
23
66
  if (placeholder) {
24
- if ('value' in properties) {
25
- properties.value = properties.value || '';
67
+ if ('value' in selectProperties) {
68
+ selectProperties.value = selectProperties.value || '';
26
69
  } else {
27
- properties.defaultValue = '';
70
+ selectProperties.defaultValue = '';
28
71
  }
29
72
  }
30
73
  return (
31
- <ChakraSelect ref={ref} {...properties}>
32
- {placeholder && (
33
- <option hidden disabled value="">
34
- {placeholder}
35
- </option>
36
- )}
37
- {children}
38
- </ChakraSelect>
74
+ <FormControl {...formControlProps}>
75
+ {label && <FormLabel>{label}</FormLabel>}
76
+ <ChakraSelect data-testid={dataTestid} ref={ref} {...selectProperties}>
77
+ {placeholder && (
78
+ <option hidden disabled value="">
79
+ {placeholder}
80
+ </option>
81
+ )}
82
+ {children}
83
+ </ChakraSelect>
84
+ {errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
85
+ {helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
86
+ </FormControl>
39
87
  );
40
88
  });
41
89
 
@@ -9,7 +9,8 @@ export default {
9
9
  export const WithProps = {
10
10
  args: {
11
11
  defaultChecked: false,
12
- helpherText:
12
+ errorText: '',
13
+ helperText:
13
14
  'Inline help. Maecenas a turpis tortor. Nunc vitae libero tempor, ullamcorper purus quis, mattis tellus.',
14
15
  isDisabled: false,
15
16
  isLoading: false,
@@ -2,7 +2,7 @@ import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
2
 
3
3
  const ToggleTheme: ComponentStyleConfig = {
4
4
  baseStyle: {
5
- formControl: {
5
+ labelWrapper: {
6
6
  display: 'flex',
7
7
  gap: '8',
8
8
  },
@@ -61,7 +61,9 @@ const ToggleTheme: ComponentStyleConfig = {
61
61
  },
62
62
  },
63
63
  label: {
64
+ fontSize: '3',
64
65
  fontWeight: 'normal',
66
+ lineHeight: '3',
65
67
  marginBottom: 0,
66
68
  },
67
69
  spinner: {
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
  import {
3
3
  FormControl,
4
4
  FormControlProps,
5
+ FormErrorMessage,
5
6
  FormHelperText,
6
7
  FormLabel,
7
8
  Spinner,
@@ -12,15 +13,18 @@ import {
12
13
  } from '@chakra-ui/react';
13
14
  import Box from '../Box/Box';
14
15
 
15
- export interface ToggleProps extends Omit<FormControlProps, 'label'> {
16
- dataTestid?: string;
16
+ export interface ToggleProps extends Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> {
17
+ 'data-testid'?: string;
17
18
  defaultChecked?: SwitchProps['defaultChecked'];
19
+ errorText?: string;
18
20
  id?: SwitchProps['id'];
19
21
  isChecked?: SwitchProps['isChecked'];
20
22
  isDisabled?: SwitchProps['isDisabled'];
21
23
  isLoading?: boolean;
22
- helpherText?: string;
24
+ helperText?: string;
23
25
  label?: ReactNode;
26
+ name?: string;
27
+ onBlur?: SwitchProps['onBlur'];
24
28
  onChange?: SwitchProps['onChange'];
25
29
  value?: SwitchProps['value'];
26
30
  }
@@ -30,31 +34,43 @@ export interface ToggleProps extends Omit<FormControlProps, 'label'> {
30
34
  */
31
35
  const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
32
36
  const {
33
- dataTestid,
37
+ 'data-testid': dataTestid,
34
38
  defaultChecked,
35
- helpherText,
39
+ errorText,
40
+ helperText,
36
41
  id,
37
42
  isChecked,
43
+ isInvalid,
38
44
  isDisabled,
39
45
  isLoading,
40
46
  label,
47
+ name,
48
+ onBlur,
41
49
  onChange,
42
50
  value,
43
51
  ...rest
44
52
  } = props;
53
+ const formControlProps = {
54
+ isDisabled: isDisabled || isLoading,
55
+ isInvalid: isInvalid || !!errorText,
56
+ ...rest,
57
+ ref,
58
+ };
45
59
  const switchProps = {
46
- dataTestid,
60
+ 'data-testid': dataTestid,
47
61
  defaultChecked,
48
62
  id,
49
63
  isChecked,
50
64
  isDisabled: isDisabled || isLoading,
65
+ name,
66
+ onBlur,
51
67
  onChange,
52
68
  value,
53
69
  };
54
70
  const css = useMultiStyleConfig('Switch');
55
71
  return (
56
- <FormControl {...rest} ref={ref}>
57
- <Box sx={css.formControl}>
72
+ <FormControl {...formControlProps}>
73
+ <Box sx={css.labelWrapper}>
58
74
  <Switch {...switchProps} />
59
75
  {label && (
60
76
  <FormLabel htmlFor={id} sx={css.label}>
@@ -63,7 +79,8 @@ const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
63
79
  )}
64
80
  {isLoading && <Spinner sx={css.spinner} />}
65
81
  </Box>
66
- {helpherText && <FormHelperText as="p">{helpherText}</FormHelperText>}
82
+ {errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
83
+ {helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
67
84
  </FormControl>
68
85
  );
69
86
  });
@@ -5,6 +5,7 @@ const shadows = {
5
5
  inner: '0 0.125rem 0.1875rem 0 rgba(0, 0, 0, 0.1) inset',
6
6
  outline: '0 0 0 3px #C289E6',
7
7
  tooltip: '0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.2)',
8
+ formFocus: '0 0.125rem 0.1875rem 0 rgba(0, 0, 0, 0.1) inset, inset 0 0 0 3px rgba(146, 71, 194, 0.3)',
8
9
  none: 'none',
9
10
  };
10
11