@bitrise/bitkit 11.1.4 → 11.2.1-alpha-chakra.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "11.1.4",
4
+ "version": "11.2.1-alpha-chakra.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -14,6 +14,7 @@ import {
14
14
  InputRightElement,
15
15
  SystemStyleObject,
16
16
  } from '@chakra-ui/react';
17
+ import { TypeColors } from '../../../Foundations/Colors/Colors';
17
18
  import Icon, { TypeIconName } from '../../Icon/Icon';
18
19
 
19
20
  type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
@@ -42,6 +43,7 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
42
43
  inputRef?: Ref<HTMLInputElement>;
43
44
  inputStyle?: SystemStyleObject;
44
45
  label?: ReactNode;
46
+ leftIconColor?: TypeColors;
45
47
  leftIconName?: TypeIconName;
46
48
  rightAddon?: ReactNode;
47
49
  rightAddonPlacement?: 'inside' | 'outside';
@@ -64,6 +66,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
64
66
  isInvalid,
65
67
  isLoading,
66
68
  label,
69
+ leftIconColor,
67
70
  leftIconName,
68
71
  max,
69
72
  maxLength,
@@ -126,7 +129,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
126
129
  <InputWrapper {...inputWrapperProps}>
127
130
  {leftIconName && (
128
131
  <InputLeftElement margin="12px" pointerEvents="none">
129
- <Icon name={leftIconName} />
132
+ <Icon color={leftIconColor} name={leftIconName} />
130
133
  </InputLeftElement>
131
134
  )}
132
135
  <ChakraInput paddingLeft={leftIconName ? '43px' : '11px'} paddingRight={inputRightPadding} {...inputProps} />
@@ -0,0 +1,52 @@
1
+ import { ChangeEvent, useState } from 'react';
2
+ import Input, { InputProps } from '../Form/Input/Input';
3
+ import IconButton from '../IconButton/IconButton';
4
+
5
+ export interface SearchInputProps extends Omit<InputProps, 'onChange'> {
6
+ onChange?: (value: string) => void;
7
+ }
8
+
9
+ const SearchInput = (props: SearchInputProps) => {
10
+ const { onChange, ...rest } = props;
11
+
12
+ const [value, setValue] = useState('');
13
+
14
+ const onInputChange = (event: ChangeEvent<HTMLInputElement>) => {
15
+ const q = event.target.value;
16
+ setValue(q);
17
+ if (onChange) {
18
+ onChange(q);
19
+ }
20
+ };
21
+
22
+ const onClearClick = () => {
23
+ setValue('');
24
+ if (onChange) {
25
+ onChange('');
26
+ }
27
+ };
28
+
29
+ const rightButton = (
30
+ <IconButton
31
+ aria-label="Clear"
32
+ iconName="CloseSmall"
33
+ onClick={onClearClick}
34
+ variant="tertiary"
35
+ _active={{ background: 'transparent' }}
36
+ _hover={{ background: 'transparent' }}
37
+ />
38
+ );
39
+ const inputProps: InputProps = {
40
+ leftIconColor: 'neutral.60',
41
+ leftIconName: 'Magnifier',
42
+ onChange: onInputChange,
43
+ rightAddon: value ? rightButton : undefined,
44
+ rightAddonPlacement: 'inside',
45
+ type: 'text',
46
+ value,
47
+ ...rest,
48
+ };
49
+ return <Input {...inputProps} />;
50
+ };
51
+
52
+ export default SearchInput;
package/src/index.ts CHANGED
@@ -227,3 +227,6 @@ export { default as ProgressBitbot } from './Components/ProgressBitbot/ProgressB
227
227
 
228
228
  export type { ProgressSpinnerProps } from './Components/ProgressSpinner/ProgressSpinner';
229
229
  export { default as ProgressSpinner } from './Components/ProgressSpinner/ProgressSpinner';
230
+
231
+ export type { SearchInputProps } from './Components/SearchInput/SearchInput';
232
+ export { default as SearchInput } from './Components/SearchInput/SearchInput';