@bitrise/bitkit 13.294.0 → 13.296.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.294.0",
4
+ "version": "13.296.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -12,6 +12,7 @@ export type LabeledDataProps = BoxProps & {
12
12
  skeletonVariant?: 'single' | 'double';
13
13
  as?: 'div' | 'dl';
14
14
  isLoading?: boolean;
15
+ isDisabled?: boolean;
15
16
  label: string;
16
17
  secondaryLabel?: ReactNode;
17
18
  size?: 'sm' | 'md' | 'lg';
@@ -29,6 +30,7 @@ const LabeledData = ({
29
30
  data,
30
31
  placeholder,
31
32
  isLoading = false,
33
+ isDisabled,
32
34
  label,
33
35
  secondaryLabel,
34
36
  size = 'sm',
@@ -41,7 +43,13 @@ const LabeledData = ({
41
43
  ...rest
42
44
  }: LabeledDataProps) => {
43
45
  const trendIconSize = size === 'sm' ? '16' : '24';
44
- const labelColor = size === 'sm' ? 'text/primary' : 'text/secondary';
46
+ let labelColor = 'text/secondary';
47
+ if (isDisabled) {
48
+ labelColor = 'text/disabled';
49
+ } else if (size === 'sm') {
50
+ labelColor = 'text/primary';
51
+ }
52
+
45
53
  let trendSign;
46
54
  if (shouldShowTrendSign) {
47
55
  trendSign = trend === 'negative' ? '-' : '+';
@@ -110,7 +118,14 @@ const LabeledData = ({
110
118
  ) : (
111
119
  <>
112
120
  {data && (
113
- <Box as="dd" display="flex" alignItems="center" gap="4" color="text/body" textStyle={`comp/data/${size}`}>
121
+ <Box
122
+ as="dd"
123
+ display="flex"
124
+ alignItems="center"
125
+ gap="4"
126
+ color={isDisabled ? 'text/disabled' : 'text/body'}
127
+ textStyle={`comp/data/${size}`}
128
+ >
114
129
  {data}
115
130
  {trendIconName && trendValue && <Icon color={trendIconColor} name={trendIconName} size={trendIconSize} />}
116
131
  </Box>
@@ -129,7 +144,7 @@ const LabeledData = ({
129
144
  </>
130
145
  )}
131
146
  {secondaryLabel && (
132
- <Text as="span" color="text/tertiary">
147
+ <Text as="span" color={isDisabled ? 'text/disabled' : 'text/tertiary'}>
133
148
  {secondaryLabel}
134
149
  </Text>
135
150
  )}
@@ -13,7 +13,19 @@ const TreeViewBranch = (props: PropsWithChildren<Omit<NodeData, 'type' | 'childr
13
13
 
14
14
  const renderTreeNodes = (nodes: NodeData[]) => {
15
15
  return nodes.map((node) => {
16
- const { id, type, title, description, iconName, iconColor, label, labelIconName, labelIconColor, children } = node;
16
+ const {
17
+ id,
18
+ type,
19
+ title,
20
+ description,
21
+ iconName,
22
+ iconColor,
23
+ label,
24
+ labelIconName,
25
+ labelIconColor,
26
+ children,
27
+ onClick,
28
+ } = node;
17
29
 
18
30
  if (type === 'branch') {
19
31
  return (
@@ -32,6 +44,7 @@ const renderTreeNodes = (nodes: NodeData[]) => {
32
44
  level={-1}
33
45
  indexPath={[]}
34
46
  titlePath={[]}
47
+ onClick={onClick}
35
48
  >
36
49
  {children && renderTreeNodes(children)}
37
50
  </TreeViewNode>
@@ -54,6 +67,7 @@ const renderTreeNodes = (nodes: NodeData[]) => {
54
67
  level={-1}
55
68
  indexPath={[]}
56
69
  titlePath={[]}
70
+ onClick={onClick}
57
71
  />
58
72
  );
59
73
  });
@@ -13,6 +13,7 @@ export type NodeData = {
13
13
  labelIconName?: TypeIconName;
14
14
  labelIconColor?: string;
15
15
  children?: NodeData[];
16
+ onClick?: VoidFunction;
16
17
  };
17
18
 
18
19
  export type NodePath = {
@@ -115,6 +115,7 @@ const TreeViewNode = ({
115
115
  label,
116
116
  labelIconName,
117
117
  labelIconColor,
118
+ onClick,
118
119
  // NodePath
119
120
  level,
120
121
  indexPath,
@@ -165,6 +166,10 @@ const TreeViewNode = ({
165
166
  },
166
167
  });
167
168
  }
169
+
170
+ if (onClick) {
171
+ onClick();
172
+ }
168
173
  }, [
169
174
  id,
170
175
  type,
@@ -7,7 +7,7 @@ const { defineMultiStyleConfig, definePartsStyle } = createMultiStyleConfigHelpe
7
7
  'footer',
8
8
  ]);
9
9
 
10
- const baseStyle = definePartsStyle({
10
+ const baseStyle = definePartsStyle((props) => ({
11
11
  container: {
12
12
  paddingTop: '16',
13
13
  display: 'grid',
@@ -17,6 +17,7 @@ const baseStyle = definePartsStyle({
17
17
  },
18
18
  data: {
19
19
  gridArea: 'data',
20
+ color: props.isDisabled ? 'text/disabled' : undefined,
20
21
  },
21
22
  actions: {
22
23
  gridArea: 'actions',
@@ -34,7 +35,7 @@ const baseStyle = definePartsStyle({
34
35
  paddingBottom: '8',
35
36
  paddingTop: '6',
36
37
  },
37
- });
38
+ }));
38
39
 
39
40
  const SettingsCardTheme = defineMultiStyleConfig({
40
41
  baseStyle,
@@ -12,12 +12,15 @@ import ToggleComponent, { ToggleComponentProps } from '../../Components/Toggle/T
12
12
 
13
13
  const [SettingsCardStyleProvider, useSettingsCardStyle] = createStylesContext('SettingsCard');
14
14
  export const SettingsCardData = ({ helperText, ...rest }: LabeledDataProps & { helperText?: string }) => {
15
- const { data } = useSettingsCardStyle();
16
- const labeledData = <LabeledData {...rest} __css={data} />;
15
+ const {
16
+ data: { color, ...dataRest },
17
+ } = useSettingsCardStyle();
18
+ const isDisabled = color === 'text/disabled';
19
+ const labeledData = <LabeledData isDisabled={isDisabled} {...rest} __css={dataRest} />;
17
20
 
18
21
  return helperText ? (
19
- <Box __css={data}>
20
- <LabeledData {...rest} secondaryLabel={helperText} />
22
+ <Box __css={dataRest}>
23
+ <LabeledData {...rest} secondaryLabel={helperText} isDisabled={isDisabled} />
21
24
  </Box>
22
25
  ) : (
23
26
  labeledData
@@ -28,10 +31,13 @@ export const SettingsCardActions = ({ children }: { children: ReactNode }) => {
28
31
  return <Box __css={actions}>{children}</Box>;
29
32
  };
30
33
  export const SettingsCardOnOffValue = (props: Pick<ToggleProps, 'isChecked' | 'valueText' | 'label'>) => {
31
- const { data } = useSettingsCardStyle();
34
+ const {
35
+ data: { color, ...rest },
36
+ } = useSettingsCardStyle();
37
+ const isDisabled = color === 'text/disabled';
32
38
  return (
33
- <Box __css={data}>
34
- <Toggle {...props} isReadOnly />
39
+ <Box __css={rest}>
40
+ <Toggle isDisabled={isDisabled} isReadOnly {...props} />
35
41
  </Box>
36
42
  );
37
43
  };
@@ -42,10 +48,14 @@ interface SettingsCardToggleProps extends Omit<ToggleProps, 'variant' | 'isReadO
42
48
  }
43
49
 
44
50
  export const SettingsCardToggle = (props: SettingsCardToggleProps) => {
45
- const { data } = useSettingsCardStyle();
51
+ const {
52
+ data: { color, ...rest },
53
+ } = useSettingsCardStyle();
54
+ const isDisabled = color === 'text/disabled';
55
+
46
56
  return (
47
- <Box __css={data}>
48
- <Toggle {...props} variant="fixed" />
57
+ <Box __css={rest}>
58
+ <Toggle isDisabled={isDisabled} variant="fixed" {...props} />
49
59
  </Box>
50
60
  );
51
61
  };
@@ -157,8 +167,8 @@ export const SettingsCardFooterStatus = ({
157
167
  </SettingsCardFooter>
158
168
  );
159
169
  };
160
- const SettingsCard = ({ children, ...props }: Omit<CardProps, 'variant'>) => {
161
- const style = useMultiStyleConfig('SettingsCard');
170
+ const SettingsCard = ({ children, isDisabled, ...props }: Omit<CardProps, 'variant'> & { isDisabled?: boolean }) => {
171
+ const style = useMultiStyleConfig('SettingsCard', { isDisabled });
162
172
  return (
163
173
  <SettingsCardStyleProvider value={style}>
164
174
  <Card variant="outline" sx={style.container} {...props}>