@bitrise/bitkit 13.126.1-alpha.1 → 13.128.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": "13.126.1-alpha.1",
4
+ "version": "13.128.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -40,8 +40,8 @@
40
40
  "@fontsource/source-code-pro": "^5.0.18",
41
41
  "framer-motion": "^11.3.6",
42
42
  "luxon": "^3.4.4",
43
- "react": "^18.2.0",
44
- "react-dom": "^18.2.0",
43
+ "react": "^18.3.1",
44
+ "react-dom": "^18.3.1",
45
45
  "react-focus-lock": "^2.12.1",
46
46
  "react-imask": "^7.6.1",
47
47
  "react-markdown": "^9.0.1"
@@ -1,4 +1,4 @@
1
- import { Switch, SwitchProps, useMultiStyleConfig } from '@chakra-ui/react';
1
+ import { forwardRef, Switch, SwitchProps, useMultiStyleConfig } from '@chakra-ui/react';
2
2
  import Skeleton from '../Skeleton/Skeleton';
3
3
  import SkeletonBox from '../Skeleton/SkeletonBox';
4
4
  import Badge from '../Badge/Badge';
@@ -7,7 +7,7 @@ export interface ToggleComponentProps extends SwitchProps {
7
7
  size?: 'md' | 'sm';
8
8
  isLoading?: boolean;
9
9
  }
10
- const ToggleComponent = (props: ToggleComponentProps) => {
10
+ const ToggleComponent = forwardRef<ToggleComponentProps, 'input'>((props, ref) => {
11
11
  const { isLoading, isReadOnly, isChecked, ...rest } = props;
12
12
  const { skeleton } = useMultiStyleConfig('Switch', props);
13
13
  if (isLoading) {
@@ -37,7 +37,7 @@ const ToggleComponent = (props: ToggleComponentProps) => {
37
37
  </Badge>
38
38
  );
39
39
  }
40
- return <Switch isReadOnly={isReadOnly} isChecked={isChecked} {...rest} />;
41
- };
40
+ return <Switch ref={ref} isReadOnly={isReadOnly} isChecked={isChecked} {...rest} />;
41
+ });
42
42
 
43
43
  export default ToggleComponent;
@@ -1,42 +1,61 @@
1
- import { BoxProps, CardProps, TextProps, useMultiStyleConfig, useStyleConfig } from '@chakra-ui/react';
1
+ import { ReactNode, useState } from 'react';
2
+ import { useMultiStyleConfig, useStyleConfig } from '@chakra-ui/react';
3
+ import Icon, { TypeIconName } from '../../Components/Icon/Icon';
2
4
  import { NOTIFICATION_STATUSES, NotificationProps } from '../../Components/Notification/Notification';
3
- import Card from '../../Components/Card/Card';
4
- import Box from '../../Components/Box/Box';
5
- import Text from '../../Components/Text/Text';
6
- import Button from '../../Components/Button/Button';
5
+ import Card, { CardProps } from '../../Components/Card/Card';
6
+ import Box, { BoxProps } from '../../Components/Box/Box';
7
+ import Text, { TextProps } from '../../Components/Text/Text';
8
+ import Button, { ButtonProps } from '../../Components/Button/Button';
9
+ import Collapse from '../../Components/Collapse/Collapse';
10
+ import Link from '../../Components/Link/Link';
7
11
 
8
12
  export type ActionProps = {
9
13
  href?: string;
10
14
  label: string;
11
- onClick?: () => void;
12
15
  target?: string;
13
- };
16
+ } & Omit<ButtonProps, 'as' | 'children' | 'size'>;
14
17
 
15
18
  export type NotificationCardProps = {
16
19
  action?: ActionProps;
17
- message: string;
18
- status: NotificationProps['status'];
20
+ message: ReactNode;
21
+ details?: ReactNode;
19
22
  title?: string;
20
- };
23
+ } & (
24
+ | {
25
+ status: NotificationProps['status'];
26
+ statusIconName?: never;
27
+ }
28
+ | {
29
+ status: 'error';
30
+ statusIconName?: Extract<TypeIconName, 'ErrorCircleFilled' | 'CrossCircle'>;
31
+ }
32
+ );
21
33
 
22
- const NotificationCardAction = ({ href, label, ...rest }: ActionProps) => {
23
- return (
24
- <Button as={(href ? 'a' : 'button') as any} variant="tertiary" size="md" href={href} {...rest}>
25
- {label}
26
- </Button>
27
- );
28
- };
29
-
30
- const NotificationCard = ({ action, status, message: description, title }: NotificationCardProps) => {
34
+ const NotificationCard = ({
35
+ action,
36
+ details,
37
+ status,
38
+ statusIconName,
39
+ message: description,
40
+ title,
41
+ }: NotificationCardProps) => {
42
+ const [isDetailsOpen, setIsDetailsOpen] = useState(false);
31
43
  const { colorScheme, defaultIcon } = NOTIFICATION_STATUSES[status || 'info'];
32
44
 
45
+ const statusIcon = statusIconName ? <Icon name={statusIconName} /> : defaultIcon;
46
+
33
47
  const style = useMultiStyleConfig('NotificationCard', { colorScheme });
34
48
  const { borderColor, bg, color } = style.card;
35
49
  const { borderRadius } = useStyleConfig('Card', { colorScheme });
36
50
 
37
51
  let actionButton;
38
52
  if (action) {
39
- actionButton = <NotificationCardAction {...action} />;
53
+ const { href, label, ...restAction } = action;
54
+ actionButton = (
55
+ <Button variant="tertiary" {...restAction} as={(href ? 'a' : 'button') as any} href={href} size="md">
56
+ {label}
57
+ </Button>
58
+ );
40
59
  }
41
60
 
42
61
  return (
@@ -56,7 +75,7 @@ const NotificationCard = ({ action, status, message: description, title }: Notif
56
75
  paddingBlock="12"
57
76
  sx={style.icon}
58
77
  >
59
- {defaultIcon}
78
+ {statusIcon}
60
79
  </Box>
61
80
  <Box
62
81
  flex="1"
@@ -73,9 +92,26 @@ const NotificationCard = ({ action, status, message: description, title }: Notif
73
92
  {title}
74
93
  </Text>
75
94
  )}
76
- <Text textStyle="body/md/regular" color={title ? '' : (color as TextProps['color'])}>
77
- {description}
78
- </Text>
95
+ <Box textStyle="body/md/regular" color={title ? '' : (color as TextProps['color'])}>
96
+ <Text>{description}</Text>
97
+ {details && (
98
+ <>
99
+ <Collapse in={isDetailsOpen}>
100
+ <Box marginTop="8">{details}</Box>
101
+ </Collapse>
102
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
103
+ <Link
104
+ as="button"
105
+ colorScheme="purple"
106
+ display="block"
107
+ marginTop="8"
108
+ onClick={() => setIsDetailsOpen(!isDetailsOpen)}
109
+ >
110
+ {isDetailsOpen ? 'Hide details' : 'Show details'}{' '}
111
+ </Link>
112
+ </>
113
+ )}
114
+ </Box>
79
115
  </Box>
80
116
  {actionButton && <Box paddingBlock="4">{actionButton}</Box>}
81
117
  </Box>