@bitrise/bitkit 12.14.1 → 12.15.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.14.1",
4
+ "version": "12.15.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -3,5 +3,6 @@ import { createContext } from '@chakra-ui/react-utils';
3
3
 
4
4
  export interface ContentSwitcherContextType {
5
5
  getRadioProps: UseRadioGroupReturn['getRadioProps'];
6
+ isGroupDisabled?: boolean;
6
7
  }
7
8
  export const [ContentSwitcherContext, useContentSwitcherContext] = createContext<ContentSwitcherContextType>();
@@ -31,6 +31,10 @@ const ContentSwitcherTheme = itemHelpers.defineMultiStyleConfig({
31
31
  _hover: {
32
32
  backgroundColor: 'neutral.100',
33
33
  borderColor: 'separator.primary',
34
+ _disabled: {
35
+ backgroundColor: 'neutral.100',
36
+ borderColor: 'separator.primary',
37
+ },
34
38
  },
35
39
  },
36
40
  _focus: {
@@ -39,6 +43,14 @@ const ContentSwitcherTheme = itemHelpers.defineMultiStyleConfig({
39
43
  _hover: {
40
44
  backgroundColor: 'neutral.93',
41
45
  borderColor: 'neutral.93',
46
+ _disabled: {
47
+ backgroundColor: 'transparent',
48
+ borderColor: 'transparent',
49
+ },
50
+ },
51
+ _disabled: {
52
+ cursor: 'not-allowed',
53
+ color: 'neutral.60',
42
54
  },
43
55
  },
44
56
  },
@@ -22,8 +22,9 @@ const ContentSwitcher = forwardRef<ContentSwitcherProps, 'div'>((props, ref) =>
22
22
  const ctx = useMemo<ContentSwitcherContextType>(
23
23
  () => ({
24
24
  getRadioProps,
25
+ isGroupDisabled: isDisabled,
25
26
  }),
26
- [getRadioProps],
27
+ [getRadioProps, isDisabled],
27
28
  );
28
29
 
29
30
  const group = getRootProps();
@@ -4,21 +4,24 @@ import { useContentSwitcherContext } from './ContentSwitcher.context';
4
4
 
5
5
  export interface ContentSwitcherItemProps {
6
6
  children: string;
7
+ isDisabled?: boolean;
7
8
  value: string;
8
9
  }
9
10
 
10
11
  const ContentSwitcherItem = (props: ContentSwitcherItemProps) => {
11
- const { getRadioProps } = useContentSwitcherContext();
12
+ const { getRadioProps, isGroupDisabled } = useContentSwitcherContext();
12
13
 
13
- const { children, value } = props;
14
+ const { children, isDisabled, value } = props;
14
15
 
15
16
  const { getInputProps, getCheckboxProps } = useRadio(getRadioProps({ value }));
16
17
 
17
18
  const theme = useMultiStyleConfig('ContentSwitcher');
18
19
 
20
+ const isItemDisabled = isGroupDisabled || isDisabled;
21
+
19
22
  return (
20
- <Box as="label" __css={theme.item} {...getCheckboxProps()}>
21
- <input {...getInputProps()} />
23
+ <Box as="label" __css={theme.item} {...getCheckboxProps()} data-disabled={isItemDisabled}>
24
+ <input {...getInputProps()} disabled={isItemDisabled} />
22
25
  {children}
23
26
  </Box>
24
27
  );
@@ -1,5 +1,5 @@
1
1
  import { forwardRef, ReactNode } from 'react';
2
- import { chakra, ChakraProps, createStylesContext, useMultiStyleConfig } from '@chakra-ui/react';
2
+ import { chakra, ChakraProps, createStylesContext, IconProps, useMultiStyleConfig } from '@chakra-ui/react';
3
3
  import { DateTime } from 'luxon';
4
4
  import Text from '../Text/Text';
5
5
  import Icon, { TypeIconName } from '../Icon/Icon';
@@ -23,6 +23,7 @@ const sidebarVariant = ({ selected, disabled }: { selected?: boolean; disabled?:
23
23
  }
24
24
  return undefined;
25
25
  };
26
+
26
27
  const SidebarItem = forwardRef(
27
28
  (
28
29
  { children, disabled, selected, href, onClick }: SidebarItemProps,
@@ -44,9 +45,9 @@ const SidebarItem = forwardRef(
44
45
  },
45
46
  );
46
47
 
47
- const SidebarItemIcon = ({ name }: { name: TypeIconName }) => {
48
+ const SidebarItemIcon = ({ name, ...iconProps }: { name: TypeIconName } & Omit<IconProps, 'sx'>) => {
48
49
  const { icon } = useSidebarItemStyle();
49
- return <Icon sx={icon} name={name} size="24" />;
50
+ return <Icon sx={icon} name={name} size="24" {...iconProps} />;
50
51
  };
51
52
 
52
53
  const SidebarItemLabel = ({ children }: { children: ReactNode }) => (
@@ -54,6 +55,7 @@ const SidebarItemLabel = ({ children }: { children: ReactNode }) => (
54
55
  {children}
55
56
  </Text>
56
57
  );
58
+
57
59
  const SidebarItemDateExtra = ({ date }: { date: Date | DateTime }) => {
58
60
  const dateTime = DateTime.isDateTime(date) ? date : DateTime.fromJSDate(date);
59
61
  return (