@bitrise/bitkit 12.98.0 → 12.100.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": "12.
|
|
4
|
+
"version": "12.100.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
|
|
@@ -55,25 +55,25 @@
|
|
|
55
55
|
"@bitrise/eslint-plugin": "^2.5.0",
|
|
56
56
|
"@chakra-ui/cli": "^2.4.1",
|
|
57
57
|
"@google-cloud/storage": "^7.7.0",
|
|
58
|
-
"@storybook/addon-actions": "^7.6.
|
|
59
|
-
"@storybook/addon-essentials": "^7.6.
|
|
60
|
-
"@storybook/addon-interactions": "^7.6.
|
|
61
|
-
"@storybook/addon-links": "^7.6.
|
|
62
|
-
"@storybook/addons": "^7.6.
|
|
63
|
-
"@storybook/blocks": "^7.6.
|
|
64
|
-
"@storybook/react": "^7.6.
|
|
65
|
-
"@storybook/react-webpack5": "^7.6.
|
|
66
|
-
"@storybook/theming": "^7.6.
|
|
58
|
+
"@storybook/addon-actions": "^7.6.12",
|
|
59
|
+
"@storybook/addon-essentials": "^7.6.12",
|
|
60
|
+
"@storybook/addon-interactions": "^7.6.12",
|
|
61
|
+
"@storybook/addon-links": "^7.6.12",
|
|
62
|
+
"@storybook/addons": "^7.6.12",
|
|
63
|
+
"@storybook/blocks": "^7.6.12",
|
|
64
|
+
"@storybook/react": "^7.6.12",
|
|
65
|
+
"@storybook/react-webpack5": "^7.6.12",
|
|
66
|
+
"@storybook/theming": "^7.6.12",
|
|
67
67
|
"@testing-library/dom": "^9.3.4",
|
|
68
|
-
"@testing-library/jest-dom": "^6.4.
|
|
69
|
-
"@testing-library/react": "^14.1
|
|
68
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
69
|
+
"@testing-library/react": "^14.2.1",
|
|
70
70
|
"@testing-library/user-event": "^14.5.2",
|
|
71
|
-
"@types/jest": "^29.5.
|
|
71
|
+
"@types/jest": "^29.5.12",
|
|
72
72
|
"@types/luxon": "^3.4.2",
|
|
73
|
-
"@types/react": "^18.2.
|
|
73
|
+
"@types/react": "^18.2.55",
|
|
74
74
|
"@types/react-dom": "^18.2.18",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
76
|
-
"@typescript-eslint/parser": "^6.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
76
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
77
77
|
"axios": "^1.6.7",
|
|
78
78
|
"eslint": "^8.56.0",
|
|
79
79
|
"eslint-plugin-import": "^2.29.1",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"jest": "^29.7.0",
|
|
89
89
|
"jest-environment-jsdom": "^29.7.0",
|
|
90
90
|
"jsdom": "^24.0.0",
|
|
91
|
-
"prettier": "^3.2.
|
|
92
|
-
"react-hook-form": "^7.
|
|
91
|
+
"prettier": "^3.2.5",
|
|
92
|
+
"react-hook-form": "^7.50.1",
|
|
93
93
|
"release-it": "^17.0.3",
|
|
94
|
-
"storybook": "^7.6.
|
|
94
|
+
"storybook": "^7.6.12",
|
|
95
95
|
"ts-jest": "^29.1.2",
|
|
96
96
|
"typescript": "^5.3.3"
|
|
97
97
|
},
|
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
|
|
2
2
|
|
|
3
|
-
const itemHelpers = createMultiStyleConfigHelpers([
|
|
3
|
+
const itemHelpers = createMultiStyleConfigHelpers([
|
|
4
|
+
'container',
|
|
5
|
+
'stage',
|
|
6
|
+
'iconWithLine',
|
|
7
|
+
'line',
|
|
8
|
+
'label',
|
|
9
|
+
'labelContainer',
|
|
10
|
+
]);
|
|
4
11
|
|
|
5
12
|
const ProgressIndicatorTheme = itemHelpers.defineMultiStyleConfig({
|
|
6
13
|
baseStyle: {
|
|
7
14
|
container: {
|
|
8
15
|
display: 'flex',
|
|
16
|
+
width: '100%',
|
|
9
17
|
},
|
|
10
18
|
iconWithLine: {
|
|
11
|
-
display: '
|
|
19
|
+
display: 'grid',
|
|
12
20
|
},
|
|
13
21
|
label: {
|
|
14
|
-
alignSelf: 'flex-start',
|
|
15
22
|
lineHeight: '1.5rem',
|
|
16
|
-
maxWidth: '
|
|
23
|
+
maxWidth: '8rem',
|
|
17
24
|
overflow: 'hidden',
|
|
25
|
+
textAlign: 'center',
|
|
18
26
|
textOverflow: 'ellipsis',
|
|
19
27
|
whiteSpace: 'nowrap',
|
|
20
28
|
},
|
|
29
|
+
labelContainer: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
},
|
|
21
33
|
line: {
|
|
22
34
|
flexGrow: '1',
|
|
23
35
|
},
|
|
24
36
|
stage: {
|
|
25
37
|
display: 'flex',
|
|
26
|
-
gap: '
|
|
38
|
+
gap: '8',
|
|
27
39
|
},
|
|
28
40
|
},
|
|
29
41
|
variants: {
|
|
@@ -32,6 +44,9 @@ const ProgressIndicatorTheme = itemHelpers.defineMultiStyleConfig({
|
|
|
32
44
|
flexDir: 'row',
|
|
33
45
|
},
|
|
34
46
|
iconWithLine: {
|
|
47
|
+
gridTemplateColumns: '1fr 24px 1fr',
|
|
48
|
+
},
|
|
49
|
+
labelContainer: {
|
|
35
50
|
flexDir: 'row',
|
|
36
51
|
},
|
|
37
52
|
line: {
|
|
@@ -46,11 +61,16 @@ const ProgressIndicatorTheme = itemHelpers.defineMultiStyleConfig({
|
|
|
46
61
|
flexDir: 'column',
|
|
47
62
|
},
|
|
48
63
|
iconWithLine: {
|
|
64
|
+
gridTemplateRows: '24px 1fr',
|
|
65
|
+
minHeight: '62px',
|
|
66
|
+
},
|
|
67
|
+
labelContainer: {
|
|
49
68
|
flexDir: 'column',
|
|
69
|
+
justifyContent: 'start',
|
|
50
70
|
},
|
|
51
71
|
line: {
|
|
52
|
-
height: '
|
|
53
|
-
|
|
72
|
+
height: '100%',
|
|
73
|
+
justifySelf: 'center',
|
|
54
74
|
},
|
|
55
75
|
stage: {
|
|
56
76
|
flexDir: 'row',
|
|
@@ -1,99 +1,205 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
1
2
|
import { useMultiStyleConfig } from '@chakra-ui/react';
|
|
2
3
|
import Box from '../Box/Box';
|
|
3
4
|
import Icon, { IconProps } from '../Icon/Icon';
|
|
4
|
-
import Text from '../Text/Text';
|
|
5
|
+
import Text, { TextProps } from '../Text/Text';
|
|
5
6
|
import Divider, { DividerProps } from '../Divider/Divider';
|
|
6
7
|
import Link, { LinkProps } from '../Link/Link';
|
|
7
8
|
|
|
9
|
+
type ProgressStage = {
|
|
10
|
+
label: string;
|
|
11
|
+
isInvalid?: boolean;
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
helperText?: string;
|
|
14
|
+
action?: {
|
|
15
|
+
onClick?: () => void;
|
|
16
|
+
href?: LinkProps['href'];
|
|
17
|
+
isExternal?: LinkProps['isExternal'];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
8
20
|
export type ProgressIndicatorProps = {
|
|
9
|
-
stages:
|
|
10
|
-
label: string;
|
|
11
|
-
isInvalid?: boolean;
|
|
12
|
-
isDisabled?: boolean;
|
|
13
|
-
action?: {
|
|
14
|
-
label: string;
|
|
15
|
-
onClick?: () => void;
|
|
16
|
-
href?: LinkProps['href'];
|
|
17
|
-
isExternal?: LinkProps['isExternal'];
|
|
18
|
-
};
|
|
19
|
-
}[];
|
|
21
|
+
stages: ProgressStage[];
|
|
20
22
|
activeStageIndex: number;
|
|
23
|
+
} & (
|
|
24
|
+
| {
|
|
25
|
+
variant: 'horizontal';
|
|
26
|
+
extendLines?: boolean;
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
variant: 'vertical';
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
type RenderStage = (ProgressStage & { spacer?: never }) | { spacer: true };
|
|
34
|
+
|
|
35
|
+
const SegmentLine = ({
|
|
36
|
+
activeSegmentIndex,
|
|
37
|
+
segmentIndex,
|
|
38
|
+
spacer,
|
|
39
|
+
variant,
|
|
40
|
+
}: {
|
|
41
|
+
segmentIndex: number;
|
|
42
|
+
activeSegmentIndex: number;
|
|
21
43
|
variant: 'horizontal' | 'vertical';
|
|
44
|
+
spacer?: true;
|
|
45
|
+
}) => {
|
|
46
|
+
const style = useMultiStyleConfig('ProgressIndicator', { variant });
|
|
47
|
+
let props: {
|
|
48
|
+
color: DividerProps['color'];
|
|
49
|
+
variant?: DividerProps['variant'];
|
|
50
|
+
} = { color: 'border.minimal' };
|
|
51
|
+
|
|
52
|
+
if (segmentIndex < activeSegmentIndex) {
|
|
53
|
+
props = { ...props, color: 'border.selected' };
|
|
54
|
+
} else if (segmentIndex === activeSegmentIndex) {
|
|
55
|
+
props = {
|
|
56
|
+
...props,
|
|
57
|
+
color: 'border.selected',
|
|
58
|
+
variant: 'dashed',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
<Divider
|
|
63
|
+
gridColumn={spacer ? '1/4' : undefined}
|
|
64
|
+
orientation={variant === 'horizontal' ? 'horizontal' : 'vertical'}
|
|
65
|
+
size="2"
|
|
66
|
+
sx={style.line}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
22
70
|
};
|
|
23
71
|
|
|
24
|
-
const
|
|
72
|
+
const RealStage = ({
|
|
73
|
+
activeSegmentIndex,
|
|
74
|
+
extendLines,
|
|
75
|
+
lastBlock,
|
|
76
|
+
segmentIndex,
|
|
77
|
+
stage: { action, helperText, isDisabled, isInvalid, label },
|
|
78
|
+
variant,
|
|
79
|
+
}: Pick<ProgressIndicatorProps, 'variant'> & {
|
|
80
|
+
segmentIndex: number;
|
|
81
|
+
activeSegmentIndex: number;
|
|
82
|
+
stage: ProgressStage;
|
|
83
|
+
lastBlock: boolean;
|
|
84
|
+
extendLines: boolean;
|
|
85
|
+
}) => {
|
|
86
|
+
let iconName: IconProps['name'];
|
|
87
|
+
let iconColor: IconProps['color'] = 'icon.interactive';
|
|
88
|
+
let textColor: TextProps['color'] = 'text.secondary';
|
|
89
|
+
let iconTransform: IconProps['transform'];
|
|
90
|
+
|
|
91
|
+
if (segmentIndex < activeSegmentIndex) {
|
|
92
|
+
iconName = 'BuildstatusSuccessfulSolid';
|
|
93
|
+
} else if (segmentIndex === activeSegmentIndex) {
|
|
94
|
+
iconName = 'StageCurrent';
|
|
95
|
+
if (variant === 'vertical') iconTransform = 'rotate(90deg)';
|
|
96
|
+
textColor = 'text.primary';
|
|
97
|
+
} else {
|
|
98
|
+
iconName = 'StageIncomplete';
|
|
99
|
+
iconColor = 'icon.tertiary';
|
|
100
|
+
}
|
|
101
|
+
if (isInvalid) {
|
|
102
|
+
iconName = 'StepstatusWarning';
|
|
103
|
+
iconColor = 'icon.negative';
|
|
104
|
+
}
|
|
105
|
+
if (isDisabled) {
|
|
106
|
+
iconColor = 'icon.disabled';
|
|
107
|
+
textColor = 'text.disabled';
|
|
108
|
+
}
|
|
25
109
|
const style = useMultiStyleConfig('ProgressIndicator', { variant });
|
|
26
110
|
|
|
27
111
|
return (
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
112
|
+
<>
|
|
113
|
+
<Box sx={style.iconWithLine}>
|
|
114
|
+
{variant === 'horizontal' &&
|
|
115
|
+
(segmentIndex > 0 ? (
|
|
116
|
+
<SegmentLine
|
|
117
|
+
activeSegmentIndex={activeSegmentIndex}
|
|
118
|
+
segmentIndex={segmentIndex - (extendLines ? 2 : 1)}
|
|
119
|
+
variant={variant}
|
|
120
|
+
/>
|
|
121
|
+
) : (
|
|
122
|
+
<div />
|
|
123
|
+
))}
|
|
124
|
+
<Icon color={iconColor} name={iconName} transform={iconTransform} />
|
|
125
|
+
{lastBlock ? (
|
|
126
|
+
<div />
|
|
127
|
+
) : (
|
|
128
|
+
<SegmentLine activeSegmentIndex={activeSegmentIndex} segmentIndex={segmentIndex} variant={variant} />
|
|
129
|
+
)}
|
|
130
|
+
</Box>
|
|
131
|
+
<Box sx={style.labelContainer}>
|
|
132
|
+
{action && !isDisabled ? (
|
|
133
|
+
<Link
|
|
134
|
+
as={action.href ? 'a' : 'button'}
|
|
135
|
+
colorScheme="purple"
|
|
136
|
+
href={action.href}
|
|
137
|
+
isExternal={action.isExternal}
|
|
138
|
+
onClick={action.onClick}
|
|
139
|
+
size="2"
|
|
140
|
+
sx={style.label}
|
|
141
|
+
>
|
|
142
|
+
{label}
|
|
143
|
+
</Link>
|
|
144
|
+
) : (
|
|
145
|
+
<Text color={textColor} size="2" sx={style.label}>
|
|
146
|
+
{label}
|
|
147
|
+
</Text>
|
|
148
|
+
)}
|
|
149
|
+
{variant === 'vertical' && helperText && (
|
|
150
|
+
<Text color="text.secondary" fontSize="1" lineHeight="1rem">
|
|
151
|
+
{helperText}
|
|
152
|
+
</Text>
|
|
153
|
+
)}
|
|
154
|
+
</Box>
|
|
155
|
+
</>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
37
158
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
}
|
|
159
|
+
const ProgressIndicator = ({ activeStageIndex, stages, ...rest }: ProgressIndicatorProps): JSX.Element => {
|
|
160
|
+
const style = useMultiStyleConfig('ProgressIndicator', { variant: rest.variant });
|
|
161
|
+
const extendLines = Boolean(rest.variant === 'horizontal' && rest.extendLines);
|
|
162
|
+
const activeSegmentIndex = extendLines ? activeStageIndex * 2 : activeStageIndex;
|
|
59
163
|
|
|
60
|
-
|
|
164
|
+
const renderStages = useMemo((): RenderStage[] => {
|
|
165
|
+
if (!extendLines) return stages;
|
|
166
|
+
const extendedStages: RenderStage[] = stages.map((stage) => ({ ...stage, type: 'real' }));
|
|
167
|
+
for (let i = 1; i < stages.length * 2 - 1; i += 2) {
|
|
168
|
+
extendedStages.splice(i, 0, { spacer: true });
|
|
169
|
+
}
|
|
170
|
+
return extendedStages;
|
|
171
|
+
}, [extendLines, stages]);
|
|
172
|
+
return (
|
|
173
|
+
<Box sx={style.container}>
|
|
174
|
+
{renderStages.map((stage, segmentIndex, array) => {
|
|
175
|
+
const lastBlock = segmentIndex === array.length - 1;
|
|
61
176
|
|
|
62
177
|
return (
|
|
63
178
|
<Box
|
|
64
179
|
// eslint-disable-next-line react/no-array-index-key
|
|
65
|
-
key={
|
|
66
|
-
|
|
67
|
-
flexGrow={lastBlock ? undefined : '1'}
|
|
180
|
+
key={segmentIndex}
|
|
181
|
+
flex="1"
|
|
68
182
|
sx={style.stage}
|
|
69
183
|
>
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
184
|
+
{!stage.spacer && (
|
|
185
|
+
<RealStage
|
|
186
|
+
activeSegmentIndex={activeSegmentIndex}
|
|
187
|
+
extendLines={Boolean(extendLines)}
|
|
188
|
+
lastBlock={lastBlock}
|
|
189
|
+
segmentIndex={segmentIndex}
|
|
190
|
+
stage={stage}
|
|
191
|
+
variant={rest.variant}
|
|
192
|
+
/>
|
|
193
|
+
)}
|
|
194
|
+
{stage.spacer && (
|
|
195
|
+
<Box sx={style.iconWithLine}>
|
|
196
|
+
<SegmentLine
|
|
197
|
+
activeSegmentIndex={activeSegmentIndex}
|
|
198
|
+
segmentIndex={segmentIndex - 1}
|
|
199
|
+
spacer
|
|
200
|
+
variant="horizontal"
|
|
78
201
|
/>
|
|
79
|
-
|
|
80
|
-
</Box>
|
|
81
|
-
{action && !isDisabled ? (
|
|
82
|
-
<Link
|
|
83
|
-
as={action.href ? 'a' : 'button'}
|
|
84
|
-
colorScheme="purple"
|
|
85
|
-
href={action.href}
|
|
86
|
-
isExternal={action.isExternal}
|
|
87
|
-
onClick={action.onClick}
|
|
88
|
-
size="2"
|
|
89
|
-
sx={style.label}
|
|
90
|
-
>
|
|
91
|
-
{label}
|
|
92
|
-
</Link>
|
|
93
|
-
) : (
|
|
94
|
-
<Text color={isDisabled ? 'neutral.80' : 'neutral.10'} size="2" sx={style.label}>
|
|
95
|
-
{label}
|
|
96
|
-
</Text>
|
|
202
|
+
</Box>
|
|
97
203
|
)}
|
|
98
204
|
</Box>
|
|
99
205
|
);
|