@bitrise/bitkit 13.65.0 → 13.66.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
|
@@ -11,14 +11,15 @@ import {
|
|
|
11
11
|
InputLeftElement,
|
|
12
12
|
InputProps as ChakraInputProps,
|
|
13
13
|
InputRightAddon,
|
|
14
|
+
InputLeftAddon,
|
|
14
15
|
InputRightElement,
|
|
15
16
|
SystemStyleObject,
|
|
17
|
+
IconProps,
|
|
16
18
|
} from '@chakra-ui/react';
|
|
17
19
|
import Icon, { TypeIconName } from '../../Icon/Icon';
|
|
18
20
|
import Text from '../../Text/Text';
|
|
19
21
|
import Box from '../../Box/Box';
|
|
20
22
|
import Tooltip, { TooltipProps } from '../../Tooltip/Tooltip';
|
|
21
|
-
import { TypeColors } from '../../../types/bitkit';
|
|
22
23
|
|
|
23
24
|
type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
|
|
24
25
|
type UsedChakraInputProps = Pick<
|
|
@@ -51,11 +52,14 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
|
|
|
51
52
|
inputStyle?: SystemStyleObject;
|
|
52
53
|
inputWrapperStyle?: SystemStyleObject;
|
|
53
54
|
label?: ReactNode;
|
|
54
|
-
|
|
55
|
+
leftAddon?: ReactNode;
|
|
56
|
+
leftAddonPlacement?: 'inside' | 'outside';
|
|
57
|
+
leftIconColor?: IconProps['color'];
|
|
55
58
|
leftIconName?: TypeIconName;
|
|
56
59
|
rightAddon?: ReactNode;
|
|
57
60
|
rightAddonPlacement?: 'inside' | 'outside';
|
|
58
61
|
rightIconName?: TypeIconName;
|
|
62
|
+
rightIconColor?: IconProps['color'];
|
|
59
63
|
withCounter?: boolean;
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -79,6 +83,8 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
79
83
|
isInvalid,
|
|
80
84
|
isLoading,
|
|
81
85
|
label,
|
|
86
|
+
leftAddon,
|
|
87
|
+
leftAddonPlacement,
|
|
82
88
|
leftIconColor,
|
|
83
89
|
leftIconName,
|
|
84
90
|
max,
|
|
@@ -93,6 +99,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
93
99
|
rightAddon,
|
|
94
100
|
rightAddonPlacement,
|
|
95
101
|
rightIconName,
|
|
102
|
+
rightIconColor,
|
|
96
103
|
role,
|
|
97
104
|
step,
|
|
98
105
|
type,
|
|
@@ -128,16 +135,22 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
128
135
|
};
|
|
129
136
|
|
|
130
137
|
let InputWrapper: any = Box;
|
|
138
|
+
|
|
131
139
|
const inputWrapperProps: SystemStyleObject = {
|
|
132
140
|
...inputWrapperStyle,
|
|
133
141
|
};
|
|
134
|
-
|
|
142
|
+
|
|
143
|
+
if (leftAddon || leftIconName || rightAddon || rightIconName) {
|
|
135
144
|
InputWrapper = InputGroup;
|
|
136
145
|
inputWrapperProps.zIndex = 0;
|
|
137
146
|
}
|
|
147
|
+
|
|
138
148
|
const RightContentWrapper = rightAddonPlacement === 'inside' ? InputRightElement : InputRightAddon;
|
|
139
149
|
const inputRightPadding = rightIconName || (rightAddon && rightAddonPlacement === 'inside') ? '43px' : '11px';
|
|
140
150
|
|
|
151
|
+
const LeftContentWrapper = leftAddonPlacement === 'inside' ? InputLeftElement : InputLeftAddon;
|
|
152
|
+
const inputLeftPadding = leftIconName || (leftAddon && leftAddonPlacement === 'inside') ? '43px' : '11px';
|
|
153
|
+
|
|
141
154
|
const [valueLength, setValueLength] = useState(value?.toString().length || 0);
|
|
142
155
|
|
|
143
156
|
const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -186,7 +199,8 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
186
199
|
</Box>
|
|
187
200
|
|
|
188
201
|
<InputWrapper {...inputWrapperProps}>
|
|
189
|
-
{
|
|
202
|
+
{leftAddon && <LeftContentWrapper>{leftAddon}</LeftContentWrapper>}
|
|
203
|
+
{!leftAddon && leftIconName && (
|
|
190
204
|
<InputLeftElement
|
|
191
205
|
marginLeft={inputHeight ? (inputHeight - iconSize) / 2 : 12}
|
|
192
206
|
pointerEvents="none"
|
|
@@ -197,7 +211,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
197
211
|
</InputLeftElement>
|
|
198
212
|
)}
|
|
199
213
|
<ChakraInput
|
|
200
|
-
paddingLeft={
|
|
214
|
+
paddingLeft={inputLeftPadding}
|
|
201
215
|
paddingRight={inputRightPadding}
|
|
202
216
|
{...inputProps}
|
|
203
217
|
onChange={onInputChange}
|
|
@@ -210,7 +224,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
210
224
|
top="50%"
|
|
211
225
|
transform="translateY(-50%)"
|
|
212
226
|
>
|
|
213
|
-
<Icon name={rightIconName} size={`${iconSize}`} />
|
|
227
|
+
<Icon color={rightIconColor} name={rightIconName} size={`${iconSize}`} />
|
|
214
228
|
</InputRightElement>
|
|
215
229
|
)}
|
|
216
230
|
</InputWrapper>
|