@bitrise/bitkit 9.14.0-alpha-chakra.5 → 9.14.0-alpha-chakra.6
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": "9.14.0-alpha-chakra.
|
|
4
|
+
"version": "9.14.0-alpha-chakra.6",
|
|
5
5
|
"repository": "git@github.com:bitrise-io/bitkit.git",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -17,17 +17,13 @@ const getDropdownStyles = (size: 'small' | 'medium'): ChakraStylesConfig => ({
|
|
|
17
17
|
borderRadius: '4',
|
|
18
18
|
boxShadow: state.isFocused ? 'outline' : 'none',
|
|
19
19
|
position: 'relative',
|
|
20
|
+
zIndex: state.isFocused ? '1' : '0',
|
|
20
21
|
}),
|
|
21
22
|
control: () => ({
|
|
22
23
|
display: 'flex',
|
|
23
24
|
...SelectTheme.baseStyle.field,
|
|
24
25
|
...SelectTheme.sizes[size].field,
|
|
25
|
-
|
|
26
|
-
dropdownIndicator: () => ({
|
|
27
|
-
position: 'absolute',
|
|
28
|
-
right: '7px',
|
|
29
|
-
top: '50%',
|
|
30
|
-
transform: 'translateY(-50%)',
|
|
26
|
+
paddingRight: '8',
|
|
31
27
|
}),
|
|
32
28
|
groupHeading: () => ({
|
|
33
29
|
display: 'flex',
|
|
@@ -46,6 +42,18 @@ const getDropdownStyles = (size: 'small' | 'medium'): ChakraStylesConfig => ({
|
|
|
46
42
|
bg: 'neutral.90',
|
|
47
43
|
},
|
|
48
44
|
}),
|
|
45
|
+
indicatorsContainer: (provided) => ({
|
|
46
|
+
...provided,
|
|
47
|
+
width: '100%',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'flex-end',
|
|
50
|
+
}),
|
|
51
|
+
loadingIndicator: () => ({
|
|
52
|
+
color: 'neutral.70',
|
|
53
|
+
width: '16',
|
|
54
|
+
height: '16',
|
|
55
|
+
marginRight: '8',
|
|
56
|
+
}),
|
|
49
57
|
menu: () => ({
|
|
50
58
|
position: 'absolute',
|
|
51
59
|
transform: 'translateY(8px)',
|
|
@@ -60,7 +68,6 @@ const getDropdownStyles = (size: 'small' | 'medium'): ChakraStylesConfig => ({
|
|
|
60
68
|
padding: '12',
|
|
61
69
|
}),
|
|
62
70
|
placeholder: () => ({
|
|
63
|
-
color: 'text.secondary',
|
|
64
71
|
...controlTextStyle,
|
|
65
72
|
}),
|
|
66
73
|
singleValue: () => controlTextStyle,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { chakraComponents, ChakraStylesConfig,
|
|
2
|
+
import { chakraComponents, ChakraStylesConfig, DropdownIndicatorProps, Props, Select } from 'chakra-react-select';
|
|
3
3
|
import Icon from '../../Old/Icon/Icon';
|
|
4
4
|
import getDropdownStyles from './Dropdown.styles';
|
|
5
5
|
|
|
6
|
-
export type DropdownProps = {
|
|
6
|
+
export type DropdownProps = Omit<Props, 'defaultValue' | 'onChange'> & {
|
|
7
|
+
defaultValue?: any;
|
|
8
|
+
onChange?: ((newValue: any) => void) | undefined;
|
|
7
9
|
size?: 'small' | 'medium';
|
|
8
|
-
}
|
|
10
|
+
};
|
|
9
11
|
|
|
10
12
|
const components = {
|
|
11
13
|
DropdownIndicator: (props: DropdownIndicatorProps) => {
|
|
@@ -18,21 +20,39 @@ const components = {
|
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
const Dropdown = (props: DropdownProps) => {
|
|
21
|
-
const { defaultValue, onChange, options, placeholder, size = 'medium' } = props;
|
|
23
|
+
const { defaultValue, isDisabled, isLoading, onChange, options, placeholder, size = 'medium' } = props;
|
|
22
24
|
const chakraStyles: ChakraStylesConfig = getDropdownStyles(size);
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const defaultValueWithLabel = defaultValue;
|
|
27
|
+
|
|
28
|
+
if (!defaultValue?.label && defaultValue?.text) {
|
|
29
|
+
defaultValueWithLabel.label = defaultValue.text;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const mappedOptions = options?.map((opt: any) => {
|
|
33
|
+
if (!opt.label && opt.text) {
|
|
34
|
+
return {
|
|
35
|
+
...opt,
|
|
36
|
+
label: opt.text,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return opt;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const properties: Props = {
|
|
43
|
+
chakraStyles,
|
|
44
|
+
components,
|
|
45
|
+
defaultValue,
|
|
46
|
+
isDisabled: isDisabled || isLoading,
|
|
47
|
+
isLoading,
|
|
48
|
+
isSearchable: false,
|
|
49
|
+
onChange,
|
|
50
|
+
options: mappedOptions,
|
|
51
|
+
placeholder,
|
|
52
|
+
selectedOptionStyle: 'check',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return <Select {...properties} />;
|
|
36
56
|
};
|
|
37
57
|
|
|
38
58
|
Dropdown.defaultProps = {
|