@bitrise/bitkit 13.216.0 → 13.217.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": "13.216.0",
4
+ "version": "13.217.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -65,13 +65,11 @@ const InputTheme = defineStyle({
65
65
  pointerEvents: 'none',
66
66
  top: '50%',
67
67
  transform: 'translateY(-50%)',
68
- left: '12',
69
68
  },
70
69
  rightIconWrapper: {
71
70
  pointerEvents: 'none',
72
71
  top: '50%',
73
72
  transform: 'translateY(-50%)',
74
- right: '12',
75
73
  },
76
74
  inputContainer: {
77
75
  position: 'relative',
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, ReactNode, Ref, useState } from 'react';
1
+ import { ChangeEvent, ReactNode, Ref, useCallback, useState } from 'react';
2
2
  import {
3
3
  FormControl,
4
4
  FormControlProps,
@@ -20,7 +20,7 @@ import {
20
20
  import Icon, { TypeIconName } from '../../Icon/Icon';
21
21
  import { TooltipProps } from '../../Tooltip/Tooltip';
22
22
  import FormLabel, { FormLabelProps } from '../FormLabel';
23
- import { getDataAttributes } from '../../../utils/utils';
23
+ import { getDataAttributes, rem } from '../../../utils/utils';
24
24
 
25
25
  type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
26
26
  type UsedChakraInputProps = Pick<
@@ -169,6 +169,22 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
169
169
  const iconSize = size === 'lg' ? '24' : '16';
170
170
  const style = useMultiStyleConfig('Input');
171
171
 
172
+ const [leftIconPos, setLeftIconPos] = useState(rem(12));
173
+
174
+ const leftAddonRef = useCallback((node: HTMLDivElement | null) => {
175
+ if (node) {
176
+ setLeftIconPos(rem(node.getBoundingClientRect().width + 12));
177
+ }
178
+ }, []);
179
+
180
+ const [rightIconPos, setRightIconPos] = useState(rem(12));
181
+
182
+ const rightAddonRef = useCallback((node: HTMLDivElement | null) => {
183
+ if (node) {
184
+ setRightIconPos(rem(node.getBoundingClientRect().width + 12));
185
+ }
186
+ }, []);
187
+
172
188
  return (
173
189
  <FormControl {...formControlProps}>
174
190
  <FormLabel
@@ -182,9 +198,9 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
182
198
  {label}
183
199
  </FormLabel>
184
200
  <InputGroup sx={style.inputContainer} {...inputWrapperStyle}>
185
- {leftAddon && <LeftContentWrapper>{leftAddon}</LeftContentWrapper>}
186
- {!leftAddon && leftIconName && (
187
- <InputLeftElement sx={style.leftIconWrapper}>
201
+ {leftAddon && <LeftContentWrapper ref={leftAddonRef}>{leftAddon}</LeftContentWrapper>}
202
+ {leftIconName && (
203
+ <InputLeftElement sx={style.leftIconWrapper} left={leftIconPos}>
188
204
  <Icon
189
205
  color={leftIconColor}
190
206
  name={leftIconName}
@@ -201,9 +217,13 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
201
217
  {...dataAttributes}
202
218
  onChange={onInputChange}
203
219
  />
204
- {rightAddon && <RightContentWrapper bottom="0">{rightAddon}</RightContentWrapper>}
205
- {!rightAddon && (rightIconName || isWarning || warningText || isInvalid) && (
206
- <InputRightElement sx={style.rightIconWrapper}>
220
+ {rightAddon && (
221
+ <RightContentWrapper ref={rightAddonRef} bottom="0">
222
+ {rightAddon}
223
+ </RightContentWrapper>
224
+ )}
225
+ {(rightIconName || isWarning || warningText || isInvalid) && (
226
+ <InputRightElement sx={style.rightIconWrapper} right={rightIconPos}>
207
227
  {rightIconName && !isWarning && !warningText && !isInvalid && (
208
228
  <Icon
209
229
  color={rightIconColor}