@shoutem/ui 7.2.2-rc.1 → 7.2.2-rc.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.
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable react/no-multi-comp */
2
2
  import React, { useEffect, useState } from 'react';
3
+ import { ActivityIndicator } from 'react-native';
3
4
  import PropTypes from 'prop-types';
4
5
  import { connectAnimation } from '@shoutem/animation';
5
6
  import { connectStyle } from '@shoutem/theme';
@@ -24,18 +25,13 @@ ClearButton.propTypes = {
24
25
  * It has a search icon, placeholder and a button that clears the current query.
25
26
  *
26
27
  */
27
- const SearchField = ({
28
- onChangeText,
29
- placeholder,
30
- style,
31
- defaultValue,
32
- ...otherProps
33
- }) => {
34
- const [text, setText] = useState(defaultValue);
28
+ const SearchField = ({ onChangeText, loading, style, ...otherProps }) => {
29
+ const [text, setText] = useState(otherProps.defaultValue);
35
30
 
36
31
  useEffect(() => {
37
32
  onChangeText(text);
38
- }, [onChangeText, text]);
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ }, [text]);
39
35
 
40
36
  return (
41
37
  <View
@@ -44,15 +40,17 @@ const SearchField = ({
44
40
  >
45
41
  <Icon name="search" style={style.searchIcon} />
46
42
  <TextInput
47
- {...otherProps}
48
43
  autoCapitalize="none"
49
44
  autoCorrect={false}
50
- onChangeText={setText}
51
- placeholder={placeholder}
52
- style={style.input}
53
45
  value={text}
46
+ style={style.input}
47
+ {...otherProps}
48
+ onChangeText={setText}
54
49
  />
55
- {!!text && <ClearButton onPress={() => setText('')} style={style} />}
50
+ {!!text && !loading && (
51
+ <ClearButton onPress={() => setText('')} style={style} />
52
+ )}
53
+ {loading && <ActivityIndicator style={style.clearButton} />}
56
54
  </View>
57
55
  );
58
56
  };
@@ -60,12 +58,12 @@ const SearchField = ({
60
58
  SearchField.propTypes = {
61
59
  style: PropTypes.object.isRequired,
62
60
  defaultValue: PropTypes.string,
63
- placeholder: PropTypes.string,
61
+ loading: PropTypes.bool,
64
62
  onChangeText: PropTypes.func,
65
63
  };
66
64
 
67
65
  SearchField.defaultProps = {
68
- placeholder: undefined,
66
+ loading: false,
69
67
  onChangeText: undefined,
70
68
  defaultValue: '',
71
69
  };
@@ -80,8 +80,8 @@ class TextInput extends PureComponent {
80
80
  underlineColorAndroid={underlineColorAndroid}
81
81
  style={{
82
82
  ...(hasBorder ? withBorder : withoutBorder),
83
- ...(errorMessage ? errorBorderColor : {}),
84
83
  ...otherStyle,
84
+ ...(errorMessage ? errorBorderColor : {}),
85
85
  height,
86
86
  }}
87
87
  ref={forwardedRef}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "7.2.2-rc.1",
3
+ "version": "7.2.2-rc.2",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
package/theme.js CHANGED
@@ -2040,7 +2040,6 @@ export default () => {
2040
2040
  clearButton: {
2041
2041
  position: 'absolute',
2042
2042
  right: 5,
2043
- top: 3,
2044
2043
  },
2045
2044
 
2046
2045
  clearIcon: {