@bitrise/bitkit 12.65.1 → 12.66.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": "12.65.1",
4
+ "version": "12.66.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -1,17 +1,30 @@
1
- import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system';
1
+ import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
2
2
 
3
- const baseStyle = defineStyle({
4
- py: '8',
5
- px: '12',
6
- bg: 'neutral.95',
7
- border: '1px solid',
8
- borderColor: 'separator.primary',
9
- borderRadius: '8',
10
- textWrap: 'wrap',
11
- wordBreak: 'break-all',
12
- overflowY: 'auto',
13
- });
3
+ const itemHelpers = createMultiStyleConfigHelpers(['container', 'codeBox', 'copyIcon']);
14
4
 
15
- export default defineStyleConfig({
16
- baseStyle,
5
+ const CodeBlockTheme = itemHelpers.defineMultiStyleConfig({
6
+ baseStyle: {
7
+ container: {
8
+ position: 'relative',
9
+ },
10
+ codeBox: {
11
+ py: '8',
12
+ px: '12',
13
+ bg: 'neutral.95',
14
+ border: '1px solid',
15
+ borderColor: 'separator.primary',
16
+ borderRadius: '8',
17
+ fontSize: '2',
18
+ textWrap: 'wrap',
19
+ wordBreak: 'break-all',
20
+ overflowY: 'auto',
21
+ },
22
+ copyIcon: {
23
+ position: 'absolute',
24
+ right: '1rem',
25
+ top: '1rem',
26
+ },
27
+ },
17
28
  });
29
+
30
+ export default CodeBlockTheme;
@@ -1,16 +1,34 @@
1
- import { ReactNode } from 'react';
2
- import { BoxProps, useStyleConfig } from '@chakra-ui/react';
1
+ import { BoxProps, useClipboard, useMultiStyleConfig } from '@chakra-ui/react';
3
2
  import Box from '../Box/Box';
3
+ import IconButton from '../IconButton/IconButton';
4
4
 
5
5
  interface CodeBlockProps extends BoxProps {
6
- children: ReactNode;
6
+ children: string;
7
+ isCopiable?: boolean;
7
8
  }
8
9
 
9
- const CodeBlock = ({ children, ...props }: CodeBlockProps) => {
10
- const css = useStyleConfig('CodeBlock');
10
+ const CodeBlock = ({ children, isCopiable, ...props }: CodeBlockProps) => {
11
+ const style = useMultiStyleConfig('CodeBlock');
12
+
13
+ const { onCopy } = useClipboard(children);
14
+
15
+ const { maxHeight, ...otherProps } = props;
16
+
11
17
  return (
12
- <Box __css={css} as="pre" {...props}>
13
- {children}
18
+ <Box sx={style.container} {...otherProps}>
19
+ <Box sx={style.codeBox} as="pre" maxHeight={maxHeight}>
20
+ {children}
21
+ </Box>
22
+ {isCopiable && (
23
+ <IconButton
24
+ iconName="Duplicate"
25
+ aria-label="Copy to clipboard"
26
+ size="small"
27
+ variant="secondary"
28
+ sx={style.copyIcon}
29
+ onClick={onCopy}
30
+ />
31
+ )}
14
32
  </Box>
15
33
  );
16
34
  };
@@ -3,12 +3,12 @@ import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system';
3
3
  const baseStyle = defineStyle(({ isCopiable }) => {
4
4
  const style = {
5
5
  fontFamily: 'mono',
6
- fontSize: '14px',
7
6
  py: '4',
8
7
  px: '8',
9
8
  borderRadius: '2',
10
9
  bg: 'neutral.95',
11
10
  width: 'fit-content',
11
+ fontSize: '2',
12
12
  };
13
13
 
14
14
  if (isCopiable) {
@@ -23,7 +23,7 @@ const defaultComponents: Components = {
23
23
  ol: ({ node, ...props }) => <List isOrdered {...props} />,
24
24
  li: ({ node, ...props }) => <ListItem {...props} />,
25
25
  code: ({ node, ...props }) => <code {...props} />,
26
- pre: ({ node, ...props }) => <CodeBlock>{props.children}</CodeBlock>,
26
+ pre: ({ node, ...props }) => <CodeBlock>{props.children as string}</CodeBlock>,
27
27
  blockquote: ({ children }) => (
28
28
  <Box
29
29
  py="8"
@@ -18,12 +18,12 @@ const ProgressIndicatorTheme = itemHelpers.defineMultiStyleConfig({
18
18
  flexGrow: '1',
19
19
  },
20
20
  label: {
21
- size: '2',
22
21
  whiteSpace: 'nowrap',
23
22
  textOverflow: 'ellipsis',
24
23
  overflow: 'hidden',
25
24
  maxWidth: 'calc(100% - 1rem)',
26
25
  lineHeight: '1.5rem',
26
+ alignSelf: 'flex-start',
27
27
  },
28
28
  },
29
29
  variants: {
@@ -1,13 +1,11 @@
1
- import { createStylesContext, useMultiStyleConfig } from '@chakra-ui/react';
1
+ import { useMultiStyleConfig } from '@chakra-ui/react';
2
2
  import Box from '../Box/Box';
3
3
  import Icon, { IconProps } from '../Icon/Icon';
4
4
  import Text from '../Text/Text';
5
5
  import Divider, { DividerProps } from '../Divider/Divider';
6
6
  import Link, { LinkProps } from '../Link/Link';
7
7
 
8
- const [ProgressIndicatorContext] = createStylesContext('ProgressIndicator');
9
-
10
- type ProgressIndicatorProps = {
8
+ export type ProgressIndicatorProps = {
11
9
  stages: {
12
10
  label: string;
13
11
  isInvalid?: boolean;
@@ -27,76 +25,75 @@ const ProgressIndicator = ({ stages, activeStageIndex, variant }: ProgressIndica
27
25
  const style = useMultiStyleConfig('ProgressIndicator', { variant });
28
26
 
29
27
  return (
30
- <ProgressIndicatorContext value={style}>
31
- <Box sx={style.container}>
32
- {stages.map(({ label, isInvalid, isDisabled, action }, index, array) => {
33
- let iconName: IconProps['name'];
34
- let iconColor: IconProps['color'] = 'purple.50';
28
+ <Box sx={style.container}>
29
+ {stages.map(({ label, isInvalid, isDisabled, action }, index, array) => {
30
+ let iconName: IconProps['name'];
31
+ let iconColor: IconProps['color'] = 'purple.50';
35
32
 
36
- let dividerProps: {
37
- color: DividerProps['color'];
38
- variant?: DividerProps['variant'];
39
- } = { color: 'neutral.93' };
33
+ let dividerProps: {
34
+ color: DividerProps['color'];
35
+ variant?: DividerProps['variant'];
36
+ } = { color: 'neutral.93' };
40
37
 
41
- if (index < activeStageIndex) {
42
- iconName = 'BuildstatusSuccessful';
43
- dividerProps = { ...dividerProps, color: 'purple.50' };
44
- } else if (index === activeStageIndex) {
45
- iconName = 'StageCurrent';
46
- dividerProps = {
47
- ...dividerProps,
48
- color: 'purple.50',
49
- variant: 'dashed',
50
- };
51
- } else {
52
- iconName = 'StageIncomplete';
53
- iconColor = 'neutral.60';
54
- }
55
- if (isInvalid) {
56
- iconName = 'StepstatusWarning';
57
- iconColor = 'red.50';
58
- }
59
- if (isDisabled) {
60
- iconColor = 'neutral.80';
61
- }
38
+ if (index < activeStageIndex) {
39
+ iconName = 'BuildstatusSuccessful';
40
+ dividerProps = { ...dividerProps, color: 'purple.50' };
41
+ } else if (index === activeStageIndex) {
42
+ iconName = 'StageCurrent';
43
+ dividerProps = {
44
+ ...dividerProps,
45
+ color: 'purple.50',
46
+ variant: 'dashed',
47
+ };
48
+ } else {
49
+ iconName = 'StageIncomplete';
50
+ iconColor = 'neutral.60';
51
+ }
52
+ if (isInvalid) {
53
+ iconName = 'StepstatusWarning';
54
+ iconColor = 'red.50';
55
+ }
56
+ if (isDisabled) {
57
+ iconColor = 'neutral.80';
58
+ }
62
59
 
63
- return (
64
- <Box
65
- width={variant === 'horizontal' ? `${100 / array.length}%` : 'auto'}
66
- sx={style.stage}
67
- // eslint-disable-next-line react/no-array-index-key
68
- key={index}
69
- >
70
- <Box sx={style.iconWithLine}>
71
- <Icon name={iconName} color={iconColor} />
72
- <Divider
73
- sx={style.line}
74
- size="2"
75
- orientation={variant === 'horizontal' ? 'horizontal' : 'vertical'}
76
- {...dividerProps}
77
- />
78
- </Box>
79
- {action && !isDisabled ? (
80
- <Link
81
- colorScheme="purple"
82
- as={action.href ? 'a' : 'button'}
83
- href={action.href}
84
- onClick={action.onClick}
85
- isExternal={action.isExternal}
86
- sx={style.label}
87
- >
88
- {label}
89
- </Link>
90
- ) : (
91
- <Text color={isDisabled ? 'neutral.80' : 'neutral.10'} sx={style.label}>
92
- {label}
93
- </Text>
94
- )}
60
+ return (
61
+ <Box
62
+ width={variant === 'horizontal' ? `${100 / array.length}%` : 'auto'}
63
+ sx={style.stage}
64
+ // eslint-disable-next-line react/no-array-index-key
65
+ key={index}
66
+ >
67
+ <Box sx={style.iconWithLine}>
68
+ <Icon name={iconName} color={iconColor} />
69
+ <Divider
70
+ sx={style.line}
71
+ size="2"
72
+ orientation={variant === 'horizontal' ? 'horizontal' : 'vertical'}
73
+ {...dividerProps}
74
+ />
95
75
  </Box>
96
- );
97
- })}
98
- </Box>
99
- </ProgressIndicatorContext>
76
+ {action && !isDisabled ? (
77
+ <Link
78
+ sx={style.label}
79
+ size="2"
80
+ colorScheme="purple"
81
+ as={action.href ? 'a' : 'button'}
82
+ href={action.href}
83
+ onClick={action.onClick}
84
+ isExternal={action.isExternal}
85
+ >
86
+ {label}
87
+ </Link>
88
+ ) : (
89
+ <Text sx={style.label} color={isDisabled ? 'neutral.80' : 'neutral.10'} size="2">
90
+ {label}
91
+ </Text>
92
+ )}
93
+ </Box>
94
+ );
95
+ })}
96
+ </Box>
100
97
  );
101
98
  };
102
99
 
package/src/index.ts CHANGED
@@ -320,3 +320,6 @@ export { default as FilterSwitchGroup } from './Components/Form/FilterSwitch/Fil
320
320
 
321
321
  export type { TablePaginationProps } from './Components/Table/TablePagination';
322
322
  export { default as TablePagination } from './Components/Table/TablePagination';
323
+
324
+ export type { ProgressIndicatorProps } from './Components/ProgressIndicator/ProgressIndicator';
325
+ export { default as ProgressIndicator } from './Components/ProgressIndicator/ProgressIndicator';