@bitrise/bitkit 13.79.0 → 13.79.1-alpha.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.79.0",
4
+ "version": "13.79.1-alpha.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -1,45 +1,46 @@
1
1
  import { defineStyle } from '@chakra-ui/styled-system';
2
+ import { rem } from '../../../utils/utils';
2
3
 
3
4
  const InputTheme = defineStyle({
4
5
  baseStyle: {
5
6
  field: {
6
7
  _disabled: {
7
8
  _hover: {
8
- borderColor: 'neutral.90',
9
+ borderColor: 'border.disabled',
9
10
  },
10
11
  _placeholder: {
11
- color: 'neutral.80',
12
+ color: 'text.disabled',
12
13
  },
13
- background: 'neutral.93',
14
+ color: 'text.disabled',
15
+ background: 'background.disabled',
14
16
  cursor: 'not-allowed',
15
17
  },
16
18
  _focusVisible: {
17
- borderColor: 'purple.50',
18
19
  boxShadow: 'formFocus',
19
20
  },
20
21
  _hover: {
21
- borderColor: 'neutral.70',
22
+ borderColor: 'border.hover',
22
23
  },
23
24
  _invalid: {
24
25
  _hover: {
25
- borderColor: 'red.50',
26
+ borderColor: 'border.error',
26
27
  },
27
- borderColor: 'red.50',
28
- color: 'red.50',
28
+ borderColor: 'border.error',
29
+ color: 'input.text.error',
29
30
  },
30
31
  _placeholder: {
31
- color: 'neutral.60',
32
+ color: 'input.text.placeholder',
32
33
  },
33
34
  _readOnly: {
34
35
  _hover: {
35
- borderColor: 'neutral.90',
36
+ borderColor: 'border.regular',
36
37
  },
37
- background: 'neutral.93',
38
+ background: 'background.disabled',
38
39
  },
39
40
  appearance: 'none',
40
- background: 'neutral.100',
41
+ background: 'background.primary',
41
42
  border: '1px solid',
42
- borderColor: 'neutral.90',
43
+ borderColor: 'border.regular',
43
44
  borderRadius: '4',
44
45
  boxShadow: 'inner',
45
46
  outline: 0,
@@ -47,6 +48,47 @@ const InputTheme = defineStyle({
47
48
  transition: '200ms',
48
49
  width: '100%',
49
50
  },
51
+ icon: {
52
+ color: 'icon.tertiary',
53
+ right: rem(11),
54
+ _groupHover: {
55
+ color: 'icon.primary',
56
+ _disabled: {
57
+ color: 'icon.on-disabled',
58
+ },
59
+ },
60
+ _disabled: {
61
+ color: 'icon.on-disabled',
62
+ },
63
+ },
64
+ inputContainer: {
65
+ position: 'relative',
66
+ },
67
+ stateIcon: {
68
+ position: 'absolute',
69
+ right: rem(16),
70
+ top: '50%',
71
+ transform: 'translateY(-50%)',
72
+ pointerEvents: 'none',
73
+ },
74
+ },
75
+ sizes: {
76
+ lg: {
77
+ field: {
78
+ fontSize: '3',
79
+ gap: '0.625rem',
80
+ height: '48',
81
+ paddingLeft: '16',
82
+ },
83
+ },
84
+ md: {
85
+ field: {
86
+ fontSize: '2',
87
+ gap: '0.375rem',
88
+ height: '40',
89
+ paddingLeft: '12',
90
+ },
91
+ },
50
92
  },
51
93
  });
52
94
 
@@ -15,6 +15,7 @@ import {
15
15
  InputRightElement,
16
16
  SystemStyleObject,
17
17
  IconProps,
18
+ useMultiStyleConfig,
18
19
  } from '@chakra-ui/react';
19
20
  import Icon, { TypeIconName } from '../../Icon/Icon';
20
21
  import Text from '../../Text/Text';
@@ -46,6 +47,7 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
46
47
  infoText?: string;
47
48
  infoTooltipProps?: TooltipProps;
48
49
  isLoading?: boolean;
50
+ isWarning?: boolean;
49
51
  helperText?: ReactNode;
50
52
  inputHeight?: number;
51
53
  inputRef?: Ref<HTMLInputElement>;
@@ -60,7 +62,9 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
60
62
  rightAddonPlacement?: 'inside' | 'outside';
61
63
  rightIconName?: TypeIconName;
62
64
  rightIconColor?: IconProps['color'];
65
+ size?: 'lg' | 'md';
63
66
  withCounter?: boolean;
67
+ warningText?: ReactNode;
64
68
  }
65
69
 
66
70
  /**
@@ -82,6 +86,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
82
86
  isDisabled,
83
87
  isInvalid,
84
88
  isLoading,
89
+ isWarning,
85
90
  label,
86
91
  leftAddon,
87
92
  leftAddonPlacement,
@@ -101,9 +106,11 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
101
106
  rightIconName,
102
107
  rightIconColor,
103
108
  role,
109
+ size = 'lg',
104
110
  step,
105
111
  type,
106
112
  value,
113
+ warningText,
107
114
  withCounter,
108
115
  ...rest
109
116
  } = props;
@@ -129,7 +136,8 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
129
136
  ref: inputRef,
130
137
  role,
131
138
  step,
132
- sx: { height: inputHeight, ...inputStyle },
139
+ size,
140
+ // sx: { height: inputHeight, ...inputStyle },
133
141
  type,
134
142
  value,
135
143
  };
@@ -162,7 +170,14 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
162
170
  };
163
171
 
164
172
  const showLabel = label || !!infoText || (withCounter && maxLength);
165
- const iconSize = inputHeight && inputHeight < 40 ? 16 : 24;
173
+
174
+ const iconNumber = inputHeight && inputHeight < 40 ? 16 : 24;
175
+
176
+ const iconSize = size === 'lg' ? '24' : '16';
177
+ const style = useMultiStyleConfig('Input', {
178
+ hasStateIcon: isInvalid || isWarning,
179
+ isPlaceholderShown: !!placeholder && !value,
180
+ });
166
181
 
167
182
  return (
168
183
  <FormControl {...formControlProps}>
@@ -170,7 +185,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
170
185
  {label && (
171
186
  <FormLabel
172
187
  optionalIndicator={
173
- <Text as="span" color="neutral.40" fontSize="2" fontWeight="normal" marginLeft="4px">
188
+ <Text as="span" color="text.secondary" fontSize="2" fontWeight="normal" marginLeft="4">
174
189
  (Optional)
175
190
  </Text>
176
191
  }
@@ -181,14 +196,14 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
181
196
  )}
182
197
  {!!infoText && (
183
198
  <Tooltip label={infoText} placement="right" {...infoTooltipProps}>
184
- <Icon color="neutral.50" name="Info" size="16" />
199
+ <Icon color="icon.tertiary" name="Info" size="16" />
185
200
  </Tooltip>
186
201
  )}
187
202
 
188
203
  {withCounter && maxLength && (
189
204
  <Text
190
205
  as="span"
191
- color="neutral.40"
206
+ color="text.secondary"
192
207
  marginInlineStart="auto"
193
208
  size="2"
194
209
  sx={{ fontVariantNumeric: 'tabular-nums' }}
@@ -198,16 +213,16 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
198
213
  )}
199
214
  </Box>
200
215
 
201
- <InputWrapper {...inputWrapperProps}>
216
+ <InputWrapper sx={style.inputContainer}>
202
217
  {leftAddon && <LeftContentWrapper>{leftAddon}</LeftContentWrapper>}
203
218
  {!leftAddon && leftIconName && (
204
219
  <InputLeftElement
205
- marginLeft={inputHeight ? (inputHeight - iconSize) / 2 : 12}
220
+ marginLeft={inputHeight ? (inputHeight - iconNumber) / 2 : 12}
206
221
  pointerEvents="none"
207
222
  top="50%"
208
223
  transform="translateY(-50%)"
209
224
  >
210
- <Icon color={leftIconColor} name={leftIconName} size={`${iconSize}`} />
225
+ <Icon color={leftIconColor} name={leftIconName} size={iconSize} data-disabled={isDisabled || undefined} />
211
226
  </InputLeftElement>
212
227
  )}
213
228
  <ChakraInput
@@ -216,20 +231,47 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
216
231
  {...inputProps}
217
232
  onChange={onInputChange}
218
233
  />
234
+ {!isInvalid && (isWarning || warningText) && (
235
+ <Icon aria-hidden="true" name="WarningColored" size={iconSize} sx={style.stateIcon} />
236
+ )}
237
+ {isInvalid && (
238
+ <Icon
239
+ aria-hidden="true"
240
+ color="icon.negative"
241
+ name="ErrorCircleFilled"
242
+ size={iconSize}
243
+ sx={style.stateIcon}
244
+ />
245
+ )}
219
246
  {rightAddon && <RightContentWrapper>{rightAddon}</RightContentWrapper>}
220
247
  {!rightAddon && rightIconName && (
221
248
  <InputRightElement
222
- marginRight={inputHeight ? (inputHeight - iconSize) / 2 : 12}
249
+ marginRight={inputHeight ? (inputHeight - iconNumber) / 2 : 12}
223
250
  pointerEvents="none"
224
251
  top="50%"
225
252
  transform="translateY(-50%)"
226
253
  >
227
- <Icon color={rightIconColor} name={rightIconName} size={`${iconSize}`} />
254
+ <Icon
255
+ color={rightIconColor}
256
+ name={rightIconName}
257
+ size={iconSize}
258
+ sx={style.icon}
259
+ data-disabled={isDisabled || undefined}
260
+ />
228
261
  </InputRightElement>
229
262
  )}
230
263
  </InputWrapper>
231
264
  {errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
232
- {helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
265
+ {!errorText && warningText && (
266
+ <FormHelperText color="text.body" as="p">
267
+ {warningText}
268
+ </FormHelperText>
269
+ )}
270
+ {!errorText && !warningText && helperText && (
271
+ <FormHelperText as="p" data-disabled={isDisabled || undefined}>
272
+ {helperText}
273
+ </FormHelperText>
274
+ )}
233
275
  </FormControl>
234
276
  );
235
277
  });
@@ -120,7 +120,11 @@ const Select = forwardRef<SelectProps, 'div'>((props, ref) => {
120
120
  )}
121
121
  </Box>
122
122
  {errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
123
- {helperText && <FormHelperText as="p">{helperText}</FormHelperText>}
123
+ {!errorText && helperText && (
124
+ <FormHelperText as="p" data-disabled={isDisabled || undefined}>
125
+ {helperText}
126
+ </FormHelperText>
127
+ )}
124
128
  </FormControl>
125
129
  );
126
130
  });