@bitrise/bitkit 10.27.0 → 10.29.0-alpha-chakra.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 +2 -1
- package/src/Components/Dropdown/Dropdown.tsx +14 -25
- package/src/Components/Form/Input/Input.stories.tsx +52 -0
- package/src/Components/Form/Input/Input.theme.ts +38 -0
- package/src/Components/Form/Input/Input.tsx +123 -0
- package/src/Components/Form/Textarea/Textarea.theme.ts +5 -30
- package/src/Components/Table/Table.stories.tsx +1 -1
- package/src/Components/Table/Tr.tsx +4 -2
- package/src/index.ts +3 -0
- package/src/old.ts +0 -3
- package/src/theme.ts +1 -1
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/Components/Input/Input.theme.ts +0 -20
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit",
|
|
3
3
|
"description": "Bitrise React component library",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.29.0-alpha-chakra.1",
|
|
5
5
|
"repository": "git@github.com:bitrise-io/bitkit.git",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@chakra-ui/react": "^2.2.4",
|
|
24
24
|
"@chakra-ui/react-utils": "^2.0.1",
|
|
25
|
+
"@chakra-ui/styled-system": "^2.3.1",
|
|
25
26
|
"@chakra-ui/utils": "^2.0.4",
|
|
26
27
|
"@emotion/react": "^11.9.3",
|
|
27
28
|
"@emotion/styled": "^11.9.3",
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import React, { cloneElement, forwardRef, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
chakra,
|
|
4
|
-
ChakraProps,
|
|
5
|
-
Input,
|
|
6
|
-
InputGroup,
|
|
7
|
-
InputLeftElement,
|
|
8
|
-
useControllableState,
|
|
9
|
-
useMultiStyleConfig,
|
|
10
|
-
} from '@chakra-ui/react';
|
|
2
|
+
import { chakra, ChakraProps, useControllableState, useMultiStyleConfig } from '@chakra-ui/react';
|
|
11
3
|
import { FloatingFocusManager, UseFloatingProps } from '@floating-ui/react-dom-interactions';
|
|
12
|
-
import
|
|
4
|
+
import { TypeIconName } from '../Icon/Icon';
|
|
5
|
+
import Input from '../Form/Input/Input';
|
|
13
6
|
import { DropdownEventArgs, DropdownProvider, useDropdownContext, useDropdownStyles } from './Dropdown.context';
|
|
14
7
|
import { DropdownOption, DropdownGroup, DropdownDetailedOption, DropdownOptionProps } from './DropdownOption';
|
|
15
8
|
import DropdownButton from './DropdownButton';
|
|
@@ -55,21 +48,17 @@ const DropdownSearch = ({
|
|
|
55
48
|
[searchOnSubmit],
|
|
56
49
|
);
|
|
57
50
|
return (
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
value={value}
|
|
70
|
-
onChange={onChangeCB}
|
|
71
|
-
/>
|
|
72
|
-
</InputGroup>
|
|
51
|
+
<Input
|
|
52
|
+
onKeyDown={onKeyDown}
|
|
53
|
+
inputRef={searchRef}
|
|
54
|
+
role="search"
|
|
55
|
+
aria-label={placeholder}
|
|
56
|
+
placeholder={placeholder}
|
|
57
|
+
value={value}
|
|
58
|
+
onChange={onChangeCB}
|
|
59
|
+
leftIconName="Magnifier"
|
|
60
|
+
sx={search}
|
|
61
|
+
/>
|
|
73
62
|
);
|
|
74
63
|
};
|
|
75
64
|
export { DropdownOption, DropdownGroup, DropdownSearch, NoResultsFound, DropdownDetailedOption };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ComponentMeta } from '@storybook/react';
|
|
2
|
+
import IconButton from '@/Components/IconButton/IconButton';
|
|
3
|
+
import Input from './Input';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
component: Input,
|
|
7
|
+
argTypes: {
|
|
8
|
+
type: {
|
|
9
|
+
control: 'inline-radio',
|
|
10
|
+
options: ['number', 'password', 'text'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
isDisabled: false,
|
|
15
|
+
isInvalid: false,
|
|
16
|
+
isLoading: false,
|
|
17
|
+
isReadOnly: false,
|
|
18
|
+
label: 'Input',
|
|
19
|
+
placeholder: 'Placeholder text',
|
|
20
|
+
type: 'text',
|
|
21
|
+
width: '400px',
|
|
22
|
+
},
|
|
23
|
+
} as ComponentMeta<typeof Input>;
|
|
24
|
+
|
|
25
|
+
export const WithProps = {
|
|
26
|
+
args: {
|
|
27
|
+
errorText: '',
|
|
28
|
+
helperText:
|
|
29
|
+
'Inline help. Maecenas a turpis tortor. Nunc vitae libero tempor, ullamcorper purus quis, mattis tellus.',
|
|
30
|
+
label: 'Input',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const WithElement = {
|
|
35
|
+
args: {
|
|
36
|
+
isDisabled: true,
|
|
37
|
+
label: 'With additional element (Like IconButton)',
|
|
38
|
+
rightElement: (
|
|
39
|
+
<IconButton aria-label="Copy to clipboard" borderLeftRadius="0" iconName="Duplicate" variant="secondary">
|
|
40
|
+
eee
|
|
41
|
+
</IconButton>
|
|
42
|
+
),
|
|
43
|
+
value: '1234567890ABCDE',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const WithIcon = {
|
|
48
|
+
args: {
|
|
49
|
+
label: 'With Icon on the left and/or right side',
|
|
50
|
+
leftIconName: 'Magnifier',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineStyle } from '@chakra-ui/styled-system';
|
|
2
|
+
|
|
3
|
+
const InputTheme = defineStyle({
|
|
4
|
+
baseStyle: {
|
|
5
|
+
field: {
|
|
6
|
+
width: '100%',
|
|
7
|
+
padding: '0.6875rem',
|
|
8
|
+
background: 'neutral.100',
|
|
9
|
+
border: '1px solid',
|
|
10
|
+
borderColor: 'neutral.90',
|
|
11
|
+
borderRadius: '4',
|
|
12
|
+
boxShadow: 'inner',
|
|
13
|
+
outline: 0,
|
|
14
|
+
appearance: 'none',
|
|
15
|
+
transition: '200ms',
|
|
16
|
+
_placeholder: {
|
|
17
|
+
fontStyle: 'italic',
|
|
18
|
+
},
|
|
19
|
+
_disabled: {
|
|
20
|
+
background: 'neutral.93',
|
|
21
|
+
cursor: 'not-allowed',
|
|
22
|
+
},
|
|
23
|
+
_focusVisible: {
|
|
24
|
+
boxShadow: 'formFocus',
|
|
25
|
+
borderColor: 'purple.50',
|
|
26
|
+
},
|
|
27
|
+
_invalid: {
|
|
28
|
+
color: 'red.50',
|
|
29
|
+
borderColor: 'red.50',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
leftElement: {
|
|
33
|
+
background: 'red',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export default InputTheme;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
FormControl,
|
|
4
|
+
FormControlProps,
|
|
5
|
+
FormErrorMessage,
|
|
6
|
+
FormHelperText,
|
|
7
|
+
FormLabel,
|
|
8
|
+
Input as ChakraInput,
|
|
9
|
+
InputProps as ChakraInputProps,
|
|
10
|
+
forwardRef,
|
|
11
|
+
InputGroup,
|
|
12
|
+
InputLeftElement,
|
|
13
|
+
InputRightElement,
|
|
14
|
+
} from '@chakra-ui/react';
|
|
15
|
+
import Icon, { TypeIconName } from '../../Icon/Icon';
|
|
16
|
+
|
|
17
|
+
export interface InputProps extends Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> {
|
|
18
|
+
'data-testid'?: string;
|
|
19
|
+
errorText?: string;
|
|
20
|
+
isLoading?: boolean;
|
|
21
|
+
helperText?: string;
|
|
22
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
23
|
+
label?: ReactNode;
|
|
24
|
+
leftIconName?: TypeIconName;
|
|
25
|
+
name?: string;
|
|
26
|
+
onBlur?: ChakraInputProps['onBlur'];
|
|
27
|
+
onChange?: ChakraInputProps['onChange'];
|
|
28
|
+
rightElement?: ReactNode;
|
|
29
|
+
rightIconName?: TypeIconName;
|
|
30
|
+
role?: ChakraInputProps['role'];
|
|
31
|
+
type?: ChakraInputProps['type'];
|
|
32
|
+
value?: ChakraInputProps['value'];
|
|
33
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes
|
|
34
|
+
autoComplete?: ChakraInputProps['autoComplete'];
|
|
35
|
+
max?: ChakraInputProps['max'];
|
|
36
|
+
maxLength?: ChakraInputProps['maxLength'];
|
|
37
|
+
min?: ChakraInputProps['min'];
|
|
38
|
+
minLength?: ChakraInputProps['minLength'];
|
|
39
|
+
pattern?: ChakraInputProps['pattern'];
|
|
40
|
+
step?: ChakraInputProps['step'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Input component is a component that is used to get user input in a text field.
|
|
45
|
+
*/
|
|
46
|
+
const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
47
|
+
const {
|
|
48
|
+
'data-testid': dataTestid,
|
|
49
|
+
autoComplete,
|
|
50
|
+
errorText,
|
|
51
|
+
helperText,
|
|
52
|
+
isDisabled,
|
|
53
|
+
inputRef,
|
|
54
|
+
isInvalid,
|
|
55
|
+
isLoading,
|
|
56
|
+
label,
|
|
57
|
+
leftIconName,
|
|
58
|
+
max,
|
|
59
|
+
maxLength,
|
|
60
|
+
min,
|
|
61
|
+
minLength,
|
|
62
|
+
pattern,
|
|
63
|
+
placeholder,
|
|
64
|
+
step,
|
|
65
|
+
onBlur,
|
|
66
|
+
onChange,
|
|
67
|
+
rightElement,
|
|
68
|
+
rightIconName,
|
|
69
|
+
name,
|
|
70
|
+
role,
|
|
71
|
+
type,
|
|
72
|
+
value,
|
|
73
|
+
...rest
|
|
74
|
+
} = props;
|
|
75
|
+
|
|
76
|
+
const formControlProps = {
|
|
77
|
+
isDisabled: isDisabled || isLoading,
|
|
78
|
+
isInvalid: isInvalid || !!errorText,
|
|
79
|
+
...rest,
|
|
80
|
+
ref,
|
|
81
|
+
};
|
|
82
|
+
const InputProps = {
|
|
83
|
+
autoComplete,
|
|
84
|
+
'data-testid': dataTestid,
|
|
85
|
+
onBlur,
|
|
86
|
+
onChange,
|
|
87
|
+
name,
|
|
88
|
+
max,
|
|
89
|
+
maxLength,
|
|
90
|
+
min,
|
|
91
|
+
minLength,
|
|
92
|
+
pattern,
|
|
93
|
+
placeholder,
|
|
94
|
+
ref: inputRef,
|
|
95
|
+
role,
|
|
96
|
+
step,
|
|
97
|
+
type,
|
|
98
|
+
value,
|
|
99
|
+
};
|
|
100
|
+
return (
|
|
101
|
+
<FormControl {...formControlProps}>
|
|
102
|
+
{label && <FormLabel>{label}</FormLabel>}
|
|
103
|
+
<InputGroup>
|
|
104
|
+
{leftIconName && (
|
|
105
|
+
<InputLeftElement margin="12px" pointerEvents="none">
|
|
106
|
+
<Icon name={leftIconName} />
|
|
107
|
+
</InputLeftElement>
|
|
108
|
+
)}
|
|
109
|
+
<ChakraInput paddingLeft={leftIconName ? '43px' : '11px'} {...InputProps} />
|
|
110
|
+
{rightElement && <InputRightElement>{rightElement}</InputRightElement>}
|
|
111
|
+
{!rightElement && rightIconName && (
|
|
112
|
+
<InputRightElement>
|
|
113
|
+
<Icon name={rightIconName} margin="12px" pointerEvents="none" />
|
|
114
|
+
</InputRightElement>
|
|
115
|
+
)}
|
|
116
|
+
</InputGroup>
|
|
117
|
+
{errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
|
|
118
|
+
{helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
|
|
119
|
+
</FormControl>
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export default Input;
|
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineStyle } from '@chakra-ui/styled-system';
|
|
2
|
+
import InputTheme from '../Input/Input.theme';
|
|
2
3
|
|
|
3
|
-
const TextareaTheme
|
|
4
|
+
const TextareaTheme = defineStyle({
|
|
4
5
|
baseStyle: {
|
|
5
|
-
|
|
6
|
+
...InputTheme.baseStyle?.field,
|
|
6
7
|
minHeight: '96',
|
|
7
|
-
padding: '16',
|
|
8
|
-
background: 'neutral.100',
|
|
9
|
-
border: '1px solid',
|
|
10
|
-
borderColor: 'neutral.90',
|
|
11
|
-
borderRadius: '4',
|
|
12
|
-
boxShadow: 'inner',
|
|
13
|
-
outline: 0,
|
|
14
|
-
appearance: 'none',
|
|
15
|
-
lineHeight: 'short',
|
|
16
|
-
verticalAlign: 'top',
|
|
17
|
-
transition: '200ms',
|
|
18
|
-
_placeholder: {
|
|
19
|
-
fontStyle: 'italic',
|
|
20
|
-
},
|
|
21
|
-
_disabled: {
|
|
22
|
-
background: 'neutral.93',
|
|
23
|
-
cursor: 'not-allowed',
|
|
24
|
-
},
|
|
25
|
-
_focusVisible: {
|
|
26
|
-
boxShadow: 'formFocus',
|
|
27
|
-
borderColor: 'purple.50',
|
|
28
|
-
},
|
|
29
|
-
_invalid: {
|
|
30
|
-
color: 'red.50',
|
|
31
|
-
borderColor: 'red.50',
|
|
32
|
-
},
|
|
33
8
|
},
|
|
34
|
-
};
|
|
9
|
+
});
|
|
35
10
|
|
|
36
11
|
export default TextareaTheme;
|
|
@@ -60,7 +60,7 @@ const Tr = forwardRef<TableRowProps, 'tr'>((props, ref) => {
|
|
|
60
60
|
<Td sx={css.expandTd}>
|
|
61
61
|
<IconButton
|
|
62
62
|
iconName="ChevronDown"
|
|
63
|
-
aria-label=
|
|
63
|
+
aria-label={isOpen ? 'Collapse row' : 'Expand row'}
|
|
64
64
|
onClick={onToggleClick}
|
|
65
65
|
size="small"
|
|
66
66
|
variant="tertiary"
|
|
@@ -76,7 +76,9 @@ const Tr = forwardRef<TableRowProps, 'tr'>((props, ref) => {
|
|
|
76
76
|
</ChakraTr>
|
|
77
77
|
<ChakraTr>
|
|
78
78
|
<Td colSpan={colSpan} paddingY="0" transform={isOpen ? 'none' : 'translateY(-1px)'}>
|
|
79
|
-
<Collapse in={isOpen}>
|
|
79
|
+
<Collapse in={isOpen} unmountOnExit>
|
|
80
|
+
{expandableContent}
|
|
81
|
+
</Collapse>
|
|
80
82
|
</Td>
|
|
81
83
|
</ChakraTr>
|
|
82
84
|
</>
|
package/src/index.ts
CHANGED
|
@@ -201,3 +201,6 @@ export { default as Collapse } from './Components/Collapse/Collapse';
|
|
|
201
201
|
|
|
202
202
|
export type { TextareaProps } from './Components/Form/Textarea/Textarea';
|
|
203
203
|
export { default as Textarea } from './Components/Form/Textarea/Textarea';
|
|
204
|
+
|
|
205
|
+
export type { InputProps } from './Components/Form/Input/Input';
|
|
206
|
+
export { default as Input } from './Components/Form/Input/Input';
|
package/src/old.ts
CHANGED
|
@@ -18,9 +18,6 @@ export { default as DatePicker } from './Old/DatePicker/DatePicker';
|
|
|
18
18
|
export type { Props as FlexProps } from './Old/Flex/Flex';
|
|
19
19
|
export { default as Flex } from './Old/Flex/Flex';
|
|
20
20
|
|
|
21
|
-
export type { Props as InputProps } from './Old/Input/Input';
|
|
22
|
-
export { default as Input } from './Old/Input/Input';
|
|
23
|
-
|
|
24
21
|
export type { Props as InputContainerProps } from './Old/Input/InputContainer';
|
|
25
22
|
export { default as InputContainer } from './Old/Input/InputContainer';
|
|
26
23
|
|
package/src/theme.ts
CHANGED
|
@@ -14,7 +14,7 @@ import List from './Components/List/List.theme';
|
|
|
14
14
|
import Menu from './Components/Menu/Menu.theme';
|
|
15
15
|
import Radio from './Components/Form/Radio/Radio.theme';
|
|
16
16
|
import Select from './Components/Select/Select.theme';
|
|
17
|
-
import Input from './Components/Input/Input.theme';
|
|
17
|
+
import Input from './Components/Form/Input/Input.theme';
|
|
18
18
|
import Dropdown from './Components/Dropdown/Dropdown.theme';
|
|
19
19
|
import Tabs from './Components/Tabs/Tabs.theme';
|
|
20
20
|
import Text from './Components/Text/Text.theme';
|