@bitrise/bitkit 9.31.0 → 9.33.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.31.0",
4
+ "version": "9.33.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -10,6 +10,7 @@ const DialogTheme: SystemStyleObject = {
10
10
  justifyContent: 'center',
11
11
  alignItems: 'flex-start',
12
12
  overflow: 'auto',
13
+ zIndex: 1000,
13
14
  },
14
15
  dialog: {
15
16
  borderRadius: '8',
@@ -33,6 +34,7 @@ const DialogTheme: SystemStyleObject = {
33
34
  body: {
34
35
  flex: 1,
35
36
  paddingX: '32',
37
+ overflow: 'auto',
36
38
  },
37
39
  footer: {
38
40
  display: 'flex',
@@ -59,6 +61,17 @@ const DialogTheme: SystemStyleObject = {
59
61
  },
60
62
  },
61
63
  full: {
64
+ dialog: {
65
+ position: 'absolute',
66
+ margin: '0',
67
+ width: 'auto',
68
+ left: '32',
69
+ right: '32',
70
+ top: '32',
71
+ bottom: '32',
72
+ },
73
+ },
74
+ mobile: {
62
75
  dialog: {
63
76
  maxW: '100vw',
64
77
  minH: '100vh',
@@ -1,4 +1,3 @@
1
- import { ReactNode } from 'react';
2
1
  import {
3
2
  Modal,
4
3
  ModalOverlay,
@@ -7,6 +6,7 @@ import {
7
6
  ModalHeader,
8
7
  useBreakpointValue,
9
8
  useDisclosure,
9
+ HTMLChakraProps,
10
10
  } from '@chakra-ui/react';
11
11
  import Icon from '../Icon/Icon';
12
12
  import Text from '../Text/Text';
@@ -25,20 +25,19 @@ export const useDialog = (): DialogState => {
25
25
  onOpen,
26
26
  };
27
27
  };
28
- export interface DialogProps {
29
- children: ReactNode;
28
+ export interface DialogProps extends HTMLChakraProps<'section'> {
30
29
  dataTestid?: string;
31
- size?: 'small' | 'medium' | 'large';
30
+ size?: 'small' | 'medium' | 'large' | 'full';
32
31
  state: DialogState;
33
32
  title: string;
34
33
  }
35
34
 
36
- const Dialog = ({ children, dataTestid, state, size, title }: DialogProps) => {
37
- const dialogSize = useBreakpointValue({ mobile: 'full', desktop: size });
35
+ const Dialog = ({ children, dataTestid, state, size, title, ...rest }: DialogProps) => {
36
+ const dialogSize = useBreakpointValue({ mobile: 'mobile', desktop: size });
38
37
  return (
39
38
  <Modal closeOnOverlayClick={false} isOpen={state.isOpen} onClose={state.onClose} size={dialogSize}>
40
39
  <ModalOverlay />
41
- <ModalContent data-testid={dataTestid}>
40
+ <ModalContent data-testid={dataTestid} {...rest}>
42
41
  <ModalHeader>
43
42
  <Text as="h1" size="5">
44
43
  {title}
@@ -1,3 +1,4 @@
1
+ import { useState } from 'react';
1
2
  import { ComponentStory, ComponentMeta } from '@storybook/react';
2
3
  import { sortObjectByKey } from '../../utils/storyUtils';
3
4
  import Select from './Select';
@@ -36,3 +37,40 @@ WithProps.args = sortObjectByKey({
36
37
  ...args,
37
38
  placeholder: 'Select build status',
38
39
  });
40
+
41
+ export const Controlled = () => {
42
+ const [value, setValue] = useState<string | undefined>(undefined);
43
+ return (
44
+ <Select w="300px" placeholder="Test holder" value={value} onChange={({ target: { value: val } }) => setValue(val)}>
45
+ {children}
46
+ </Select>
47
+ );
48
+ };
49
+
50
+ export const WithLoading = () => (
51
+ <>
52
+ <Select w="300px" isDisabled placeholder="Test holder">
53
+ {children}
54
+ </Select>
55
+ <Select w="300px" isLoading>
56
+ {children}
57
+ </Select>
58
+ </>
59
+ );
60
+
61
+ export const WithLoadingOnChange = () => {
62
+ const [loading, setLoading] = useState(false);
63
+
64
+ return (
65
+ <Select
66
+ w="240px"
67
+ isLoading={loading}
68
+ onChange={() => {
69
+ setLoading(true);
70
+ setTimeout(() => setLoading(false), 3000);
71
+ }}
72
+ >
73
+ {children}
74
+ </Select>
75
+ );
76
+ };
@@ -1,30 +1,43 @@
1
- import { Select as ChakraSelect, SelectProps as ChakraSelectProps } from '@chakra-ui/react';
1
+ import { forwardRef, Select as ChakraSelect, SelectProps as ChakraSelectProps, Spinner } from '@chakra-ui/react';
2
2
  import Icon from '../Icon/Icon';
3
3
 
4
4
  export interface SelectProps extends ChakraSelectProps {
5
5
  size?: 'small' | 'medium';
6
+ isLoading?: boolean;
6
7
  }
7
8
 
8
- const Select = (props: SelectProps) => {
9
- const { size, placeholder, children, ...rest } = props;
9
+ const Select = forwardRef<SelectProps, 'select'>((props, ref) => {
10
+ const { size, placeholder, children, isDisabled, isLoading, ...rest } = props;
10
11
  const iconSize = size === 'medium' ? '24' : '16';
11
12
  const properties: ChakraSelectProps = {
12
- icon: <Icon name="DropdownArrows" fontSize={iconSize} size={iconSize} />,
13
+ icon: isLoading ? (
14
+ <Spinner width={iconSize} height={iconSize} marginEnd="4" />
15
+ ) : (
16
+ <Icon name="DropdownArrows" fontSize={iconSize} size={iconSize} />
17
+ ),
18
+ isDisabled: isLoading || isDisabled,
13
19
  size,
14
20
  variant: 'select',
15
21
  ...rest,
16
22
  };
23
+ if (placeholder) {
24
+ if ('value' in properties) {
25
+ properties.value = properties.value || '';
26
+ } else {
27
+ properties.defaultValue = '';
28
+ }
29
+ }
17
30
  return (
18
- <ChakraSelect {...properties}>
31
+ <ChakraSelect ref={ref} {...properties}>
19
32
  {placeholder && (
20
- <option selected hidden disabled value="">
33
+ <option hidden disabled value="">
21
34
  {placeholder}
22
35
  </option>
23
36
  )}
24
37
  {children}
25
38
  </ChakraSelect>
26
39
  );
27
- };
40
+ });
28
41
 
29
42
  Select.defaultProps = {
30
43
  size: 'medium',