@bitrise/bitkit 10.32.0 → 10.32.2

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": "10.32.0",
4
+ "version": "10.32.2",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -1,4 +1,5 @@
1
1
  import { ComponentMeta } from '@storybook/react';
2
+ import Button from '@/Components/Button/Button';
2
3
  import IconButton from '@/Components/IconButton/IconButton';
3
4
  import Input from './Input';
4
5
 
@@ -18,7 +19,6 @@ export default {
18
19
  label: 'Input',
19
20
  placeholder: 'Placeholder text',
20
21
  type: 'text',
21
- width: '400px',
22
22
  },
23
23
  } as ComponentMeta<typeof Input>;
24
24
 
@@ -31,19 +31,38 @@ export const WithProps = {
31
31
  },
32
32
  };
33
33
 
34
- export const WithElement = {
34
+ export const WithElementOutside = {
35
35
  args: {
36
36
  isDisabled: true,
37
- label: 'With additional element (Like IconButton)',
37
+ label: 'With additional element outside (Like Button)',
38
38
  rightAddon: (
39
- <IconButton aria-label="Copy to clipboard" borderLeftRadius="0" iconName="Duplicate" variant="secondary">
40
- eee
41
- </IconButton>
39
+ <Button borderLeftRadius="0" leftIconName="Duplicate" variant="secondary">
40
+ Copy to clipboard
41
+ </Button>
42
42
  ),
43
+ rightAddonPlacement: 'outside',
43
44
  value: '1234567890ABCDE',
44
45
  },
45
46
  };
46
47
 
48
+ export const WithElementInside = {
49
+ args: {
50
+ label: 'With additional element inside (Like IconButton)',
51
+ rightAddon: (
52
+ <IconButton
53
+ aria-label="Search"
54
+ borderLeftRadius="0"
55
+ iconName="Magnifier"
56
+ variant="tertiary"
57
+ _active={{ background: 'transparent' }}
58
+ _hover={{ background: 'transparent' }}
59
+ />
60
+ ),
61
+ rightAddonPlacement: 'inside',
62
+ width: '100%',
63
+ },
64
+ };
65
+
47
66
  export const WithIcon = {
48
67
  args: {
49
68
  label: 'With Icon on the left and/or right side',
@@ -40,9 +40,11 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
40
40
  isLoading?: boolean;
41
41
  helperText?: ReactNode;
42
42
  inputRef?: Ref<HTMLInputElement>;
43
+ inputStyle?: SystemStyleObject;
43
44
  label?: ReactNode;
44
45
  leftIconName?: TypeIconName;
45
46
  rightAddon?: ReactNode;
47
+ rightAddonPlacement?: 'inside' | 'outside';
46
48
  rightIconName?: TypeIconName;
47
49
  }
48
50
 
@@ -58,6 +60,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
58
60
  helperText,
59
61
  isDisabled,
60
62
  inputRef,
63
+ inputStyle,
61
64
  isInvalid,
62
65
  isLoading,
63
66
  label,
@@ -72,6 +75,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
72
75
  onBlur,
73
76
  onChange,
74
77
  rightAddon,
78
+ rightAddonPlacement,
75
79
  rightIconName,
76
80
  name,
77
81
  role,
@@ -102,6 +106,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
102
106
  ref: inputRef,
103
107
  role,
104
108
  step,
109
+ sx: inputStyle,
105
110
  type,
106
111
  value,
107
112
  };
@@ -112,6 +117,9 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
112
117
  InputWrapper = InputGroup;
113
118
  inputWrapperProps.zIndex = 0;
114
119
  }
120
+ const RightContentWrapper = rightAddonPlacement === 'inside' ? InputRightElement : InputRightAddon;
121
+ const inputRightPadding = rightIconName || (rightAddon && rightAddonPlacement === 'inside') ? '43px' : '11px';
122
+
115
123
  return (
116
124
  <FormControl {...formControlProps}>
117
125
  {label && <FormLabel>{label}</FormLabel>}
@@ -121,12 +129,8 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
121
129
  <Icon name={leftIconName} />
122
130
  </InputLeftElement>
123
131
  )}
124
- <ChakraInput
125
- paddingLeft={leftIconName ? '43px' : '11px'}
126
- paddingRight={rightIconName ? '43px' : '11px'}
127
- {...inputProps}
128
- />
129
- {rightAddon && <InputRightAddon>{rightAddon}</InputRightAddon>}
132
+ <ChakraInput paddingLeft={leftIconName ? '43px' : '11px'} paddingRight={inputRightPadding} {...inputProps} />
133
+ {rightAddon && <RightContentWrapper>{rightAddon}</RightContentWrapper>}
130
134
  {!rightAddon && rightIconName && (
131
135
  <InputRightElement margin="12px" pointerEvents="none">
132
136
  <Icon name={rightIconName} />