@bitrise/bitkit 13.20.0 → 13.22.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.20.0",
4
+ "version": "13.22.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -47,7 +47,7 @@ const DropdownTheme = {
47
47
  },
48
48
  _disabled: {
49
49
  color: 'neutral.70',
50
- pointerEvents: 'none',
50
+ cursor: 'not-allowed',
51
51
  },
52
52
  color: 'purple.10',
53
53
  cursor: 'pointer',
@@ -123,7 +123,7 @@ function findOption<T>(children: ReactNode, value: T): { label: ReactNode; index
123
123
  const list = React.Children.toArray(children);
124
124
  for (let i = 0; i < list.length; i++) {
125
125
  const elem = list[i];
126
- if (React.isValidElement(elem)) {
126
+ if (React.isValidElement(elem) && !elem.props.isDisabled) {
127
127
  const optValue = typeof elem.props.value === 'undefined' ? null : elem.props.value;
128
128
  if (elem.type === DropdownOption && optValue === value) {
129
129
  return { index: elem.props.index, label: elem.props.children };
@@ -38,15 +38,19 @@ const DropdownOption = <T = string,>({
38
38
  value === ctx.formValue && 'bitkit-select__option-active',
39
39
  index === ctx.activeIndex && 'bitkit-select__option-hover',
40
40
  )}
41
- {...ctx.getItemProps({
42
- onClick(event) {
43
- onClick?.(event);
41
+ {...ctx.getItemProps(
42
+ isDisabled
43
+ ? {}
44
+ : {
45
+ onClick(event) {
46
+ onClick?.(event);
44
47
 
45
- if (!event.defaultPrevented) {
46
- ctx.onOptionSelected({ index, label: children, value });
47
- }
48
- },
49
- })}
48
+ if (!event.defaultPrevented) {
49
+ ctx.onOptionSelected({ index, label: children, value });
50
+ }
51
+ },
52
+ },
53
+ )}
50
54
  >
51
55
  {children}
52
56
  </chakra.div>
@@ -77,27 +81,26 @@ const DropdownGroup = ({
77
81
  );
78
82
  };
79
83
 
80
- const DropdownDetailedOption = ({
84
+ type DropdownDetailedOptionProps<T> = DropdownOptionProps<T> & {
85
+ icon: ReactNode;
86
+ subtitle: string;
87
+ title: string;
88
+ };
89
+
90
+ const DropdownDetailedOption = <T = string,>({
81
91
  icon,
82
- subtitle,
83
92
  title,
84
- value,
93
+ isDisabled,
94
+ subtitle,
85
95
  ...rest
86
- }: {
87
- icon: ReactNode;
88
- title: string;
89
- subtitle: string;
90
- value?: string;
91
- }) => {
96
+ }: DropdownDetailedOptionProps<T>) => {
92
97
  return (
93
- <DropdownOption value={value} {...rest} aria-label={title}>
98
+ <DropdownOption isDisabled={isDisabled} {...rest} aria-label={title}>
94
99
  <chakra.div alignItems="center" display="flex" flexDir="row" gap="12">
95
- {icon}
100
+ <chakra.div opacity={isDisabled ? '0.5' : '1'}>{icon}</chakra.div>
96
101
  <chakra.div>
97
- <Text color="purple.10" size="3">
98
- {title}
99
- </Text>
100
- <Text color="neutral.60" size="2">
102
+ {title}
103
+ <Text color={isDisabled ? 'text/disabled' : 'input/text/helper'} size="2">
101
104
  {subtitle}
102
105
  </Text>
103
106
  </chakra.div>
@@ -4,13 +4,17 @@ import ReactMarkdown, { Components } from 'react-markdown';
4
4
  import List from '../List/List';
5
5
  import Link from '../Link/Link';
6
6
  import ListItem from '../List/ListItem';
7
- import Box from '../Box/Box';
7
+ import Box, { BoxProps } from '../Box/Box';
8
8
  import Divider from '../Divider/Divider';
9
9
  import Text from '../Text/Text';
10
10
  import CodeBlock from '../CodeBlock/CodeBlock';
11
11
  import CodeSnippet from '../CodeSnippet/CodeSnippet';
12
12
 
13
- const defaultComponents = (size: 'md' | 'lg'): Components => {
13
+ type GapType = Exclude<BoxProps['gap'], undefined>;
14
+
15
+ const defaultComponents = (size: 'sm' | 'md' | 'lg', gap: GapType = '16'): Components => {
16
+ const codeSize = size === 'lg' ? 'lg' : 'md';
17
+
14
18
  return {
15
19
  a: ({ node, ...props }) => <Link colorScheme="purple" isUnderlined target="_blank" {...props} />,
16
20
  blockquote: ({ children }) => (
@@ -27,7 +31,7 @@ const defaultComponents = (size: 'md' | 'lg'): Components => {
27
31
  </Box>
28
32
  ),
29
33
  code: ({ node, ...props }) => (
30
- <CodeSnippet size={size} {...props}>
34
+ <CodeSnippet size={codeSize} {...props}>
31
35
  {props.children as string}
32
36
  </CodeSnippet>
33
37
  ),
@@ -37,24 +41,26 @@ const defaultComponents = (size: 'md' | 'lg'): Components => {
37
41
  h4: ({ node, ...props }) => <Text as="h4" textStyle="heading/h4" {...props} />,
38
42
  h5: ({ node, ...props }) => <Text as="h5" textStyle="heading/h5" {...props} />,
39
43
  h6: ({ node, ...props }) => <Text as="h6" textStyle="heading/h6" {...props} />,
40
- hr: () => <Divider borderColor="separator.primary" my="16" size="2" />,
44
+ hr: () => <Divider borderColor="separator.primary" my={gap} size="2" />,
41
45
  li: ({ node, ...props }) => <ListItem {...props} />,
42
46
  ol: ({ node, ...props }) => <List isOrdered {...props} />,
43
47
  p: ({ node, ...props }) => <Text {...props} />,
44
- pre: ({ node, ...props }) => <CodeBlock size={size}>{props.children as string}</CodeBlock>,
48
+ pre: ({ node, ...props }) => <CodeBlock size={codeSize}>{props.children as string}</CodeBlock>,
45
49
  ul: ({ node, ...props }) => <List {...props} />,
46
50
  };
47
51
  };
48
52
 
49
- type NoteMarkdownContentProps = { md: string; size?: 'md' | 'lg' } & Pick<
50
- ComponentProps<typeof ReactMarkdown>,
51
- 'components' | 'rehypePlugins'
52
- >;
53
- const NoteMarkdownContent = ({ components, md, size = 'lg', ...rest }: NoteMarkdownContentProps) => {
53
+ type NoteMarkdownContentProps = {
54
+ md: string;
55
+ gap?: GapType;
56
+ size?: 'sm' | 'md' | 'lg';
57
+ } & Pick<ComponentProps<typeof ReactMarkdown>, 'components' | 'rehypePlugins'>;
58
+
59
+ const NoteMarkdownContent = ({ components, md, gap = '16', size = 'lg', ...rest }: NoteMarkdownContentProps) => {
54
60
  const extendedComponents = { ...defaultComponents(size), ...components };
55
61
  const textStyle = `body/${size}/regular`;
56
62
  return (
57
- <Box display="flex" flexDirection="column" gap="16" textStyle={textStyle}>
63
+ <Box display="flex" flexDirection="column" gap={gap} textStyle={textStyle}>
58
64
  <ReactMarkdown components={extendedComponents} {...rest}>
59
65
  {md}
60
66
  </ReactMarkdown>