@bitrise/bitkit 10.31.0 → 10.31.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
|
@@ -35,7 +35,7 @@ export const WithElement = {
|
|
|
35
35
|
args: {
|
|
36
36
|
isDisabled: true,
|
|
37
37
|
label: 'With additional element (Like IconButton)',
|
|
38
|
-
|
|
38
|
+
rightAddon: (
|
|
39
39
|
<IconButton aria-label="Copy to clipboard" borderLeftRadius="0" iconName="Duplicate" variant="secondary">
|
|
40
40
|
eee
|
|
41
41
|
</IconButton>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, Ref } from 'react';
|
|
1
|
+
import { Fragment, ReactNode, Ref } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
FormControl,
|
|
4
4
|
FormControlProps,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
forwardRef,
|
|
11
11
|
InputGroup,
|
|
12
12
|
InputLeftElement,
|
|
13
|
+
InputRightAddon,
|
|
13
14
|
InputRightElement,
|
|
14
15
|
} from '@chakra-ui/react';
|
|
15
16
|
import Icon, { TypeIconName } from '../../Icon/Icon';
|
|
@@ -40,7 +41,7 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
|
|
|
40
41
|
inputRef?: Ref<HTMLInputElement>;
|
|
41
42
|
label?: ReactNode;
|
|
42
43
|
leftIconName?: TypeIconName;
|
|
43
|
-
|
|
44
|
+
rightAddon?: ReactNode;
|
|
44
45
|
rightIconName?: TypeIconName;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -69,7 +70,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
69
70
|
step,
|
|
70
71
|
onBlur,
|
|
71
72
|
onChange,
|
|
72
|
-
|
|
73
|
+
rightAddon,
|
|
73
74
|
rightIconName,
|
|
74
75
|
name,
|
|
75
76
|
role,
|
|
@@ -103,10 +104,12 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
103
104
|
type,
|
|
104
105
|
value,
|
|
105
106
|
};
|
|
107
|
+
|
|
108
|
+
const InputWrapper = leftIconName || rightAddon || rightIconName ? InputGroup : Fragment;
|
|
106
109
|
return (
|
|
107
110
|
<FormControl {...formControlProps}>
|
|
108
111
|
{label && <FormLabel>{label}</FormLabel>}
|
|
109
|
-
<
|
|
112
|
+
<InputWrapper>
|
|
110
113
|
{leftIconName && (
|
|
111
114
|
<InputLeftElement margin="12px" pointerEvents="none">
|
|
112
115
|
<Icon name={leftIconName} />
|
|
@@ -117,13 +120,13 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
117
120
|
paddingRight={rightIconName ? '43px' : '11px'}
|
|
118
121
|
{...inputProps}
|
|
119
122
|
/>
|
|
120
|
-
{
|
|
121
|
-
{!
|
|
123
|
+
{rightAddon && <InputRightAddon>{rightAddon}</InputRightAddon>}
|
|
124
|
+
{!rightAddon && rightIconName && (
|
|
122
125
|
<InputRightElement margin="12px" pointerEvents="none">
|
|
123
126
|
<Icon name={rightIconName} />
|
|
124
127
|
</InputRightElement>
|
|
125
128
|
)}
|
|
126
|
-
</
|
|
129
|
+
</InputWrapper>
|
|
127
130
|
{errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
|
|
128
131
|
{helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
|
|
129
132
|
</FormControl>
|